/home/ntakagi/work/STLport-5.1.5/stlport/stl/_stack.hGo to the documentation of this file.00001 /* 00002 * 00003 * Copyright (c) 1994 00004 * Hewlett-Packard Company 00005 * 00006 * Copyright (c) 1996,1997 00007 * Silicon Graphics Computer Systems, Inc. 00008 * 00009 * Copyright (c) 1997 00010 * Moscow Center for SPARC Technology 00011 * 00012 * Copyright (c) 1999 00013 * Boris Fomitchev 00014 * 00015 * This material is provided "as is", with absolutely no warranty expressed 00016 * or implied. Any use is at your own risk. 00017 * 00018 * Permission to use or copy this software for any purpose is hereby granted 00019 * without fee, provided the above notices are retained on all copies. 00020 * Permission to modify the code and to distribute modified code is granted, 00021 * provided the above notices are retained, and a notice that the code was 00022 * modified is included with the above copyright notice. 00023 * 00024 */ 00025 00026 /* NOTE: This is an internal header file, included by other STL headers. 00027 * You should not attempt to use it directly. 00028 */ 00029 00030 #ifndef _STLP_INTERNAL_STACK_H 00031 #define _STLP_INTERNAL_STACK_H 00032 00033 #ifndef _STLP_INTERNAL_DEQUE_H 00034 # include <stl/_deque.h> 00035 #endif 00036 00037 _STLP_BEGIN_NAMESPACE 00038 00039 #if !defined ( _STLP_LIMITED_DEFAULT_TEMPLATES ) 00040 template <class _Tp, class _Sequence = deque<_Tp> > 00041 #elif defined ( _STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS ) 00042 # define _STLP_STACK_ARGS _Tp 00043 template <class _Tp> 00044 #else 00045 template <class _Tp, class _Sequence> 00046 #endif 00047 class stack 00048 #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) 00049 # if defined (_STLP_STACK_ARGS) 00050 : public __stlport_class<stack<_Tp> > 00051 # else 00052 : public __stlport_class<stack<_Tp, _Sequence> > 00053 # endif 00054 #endif 00055 { 00056 #ifdef _STLP_STACK_ARGS 00057 typedef deque<_Tp> _Sequence; 00058 typedef stack<_Tp> _Self; 00059 #else 00060 typedef stack<_Tp, _Sequence> _Self; 00061 #endif 00062 00063 public: 00064 typedef typename _Sequence::value_type value_type; 00065 typedef typename _Sequence::size_type size_type; 00066 typedef _Sequence container_type; 00067 00068 typedef typename _Sequence::reference reference; 00069 typedef typename _Sequence::const_reference const_reference; 00070 protected: 00071 //c is a Standard name (23.2.3.3), do no make it STLport naming convention compliant. 00072 _Sequence c; 00073 public: 00074 stack() : c() {} 00075 explicit stack(const _Sequence& __s) : c(__s) {} 00076 00077 stack(__move_source<_Self> src) 00078 : c(_STLP_PRIV _AsMoveSource(src.get().c)) {} 00079 00080 bool empty() const { return c.empty(); } 00081 size_type size() const { return c.size(); } 00082 reference top() { return c.back(); } 00083 const_reference top() const { return c.back(); } 00084 void push(const value_type& __x) { c.push_back(__x); } 00085 void pop() { c.pop_back(); } 00086 const _Sequence& _Get_s() const { return c; } 00087 }; 00088 00089 #ifndef _STLP_STACK_ARGS 00090 # define _STLP_STACK_ARGS _Tp, _Sequence 00091 # define _STLP_STACK_HEADER_ARGS class _Tp, class _Sequence 00092 #else 00093 # define _STLP_STACK_HEADER_ARGS class _Tp 00094 #endif 00095 00096 template < _STLP_STACK_HEADER_ARGS > 00097 inline bool _STLP_CALL operator==(const stack< _STLP_STACK_ARGS >& __x, 00098 const stack< _STLP_STACK_ARGS >& __y) 00099 { return __x._Get_s() == __y._Get_s(); } 00100 00101 template < _STLP_STACK_HEADER_ARGS > 00102 inline bool _STLP_CALL operator<(const stack< _STLP_STACK_ARGS >& __x, 00103 const stack< _STLP_STACK_ARGS >& __y) 00104 { return __x._Get_s() < __y._Get_s(); } 00105 00106 _STLP_RELOPS_OPERATORS(template < _STLP_STACK_HEADER_ARGS >, stack< _STLP_STACK_ARGS >) 00107 00108 #undef _STLP_STACK_ARGS 00109 #undef _STLP_STACK_HEADER_ARGS 00110 00111 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) 00112 template <class _Tp, class _Sequence> 00113 struct __move_traits<stack<_Tp, _Sequence> > : 00114 _STLP_PRIV __move_traits_aux<_Sequence> 00115 {}; 00116 #endif 00117 00118 _STLP_END_NAMESPACE 00119 00120 #endif /* _STLP_INTERNAL_STACK_H */ 00121 00122 // Local Variables: 00123 // mode:C++ 00124 // End:
Generated on Mon Mar 10 15:32:36 2008 by ![]() |