Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef EIGEN_STDDEQUE_H
00027 #define EIGEN_STDDEQUE_H
00028
00029 #include "Eigen/src/StlSupport/details.h"
00030
00031
00032 #if defined(__INTEL_COMPILER) || defined(__GNUC__)
00033 #define EIGEN_EXPLICIT_STL_DEQUE_INSTANTIATION(...) template class std::deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> >;
00034 #else
00035 #define EIGEN_EXPLICIT_STL_DEQUE_INSTANTIATION(...)
00036 #endif
00037
00043 #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) \
00044 EIGEN_EXPLICIT_STL_DEQUE_INSTANTIATION(__VA_ARGS__) \
00045 namespace std \
00046 { \
00047 template<typename _Ay> \
00048 class deque<__VA_ARGS__, _Ay> \
00049 : public deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
00050 { \
00051 typedef deque<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > deque_base; \
00052 public: \
00053 typedef __VA_ARGS__ value_type; \
00054 typedef typename deque_base::allocator_type allocator_type; \
00055 typedef typename deque_base::size_type size_type; \
00056 typedef typename deque_base::iterator iterator; \
00057 explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \
00058 template<typename InputIterator> \
00059 deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : deque_base(first, last, a) {} \
00060 deque(const deque& c) : deque_base(c) {} \
00061 explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \
00062 deque(iterator start, iterator end) : deque_base(start, end) {} \
00063 deque& operator=(const deque& x) { \
00064 deque_base::operator=(x); \
00065 return *this; \
00066 } \
00067 }; \
00068 }
00069
00070
00071 #if !(defined(_GLIBCXX_DEQUE) && (!EIGEN_GNUC_AT_LEAST(4,1)))
00072
00073 namespace std {
00074
00075 #define EIGEN_STD_DEQUE_SPECIALIZATION_BODY \
00076 public: \
00077 typedef T value_type; \
00078 typedef typename deque_base::allocator_type allocator_type; \
00079 typedef typename deque_base::size_type size_type; \
00080 typedef typename deque_base::iterator iterator; \
00081 typedef typename deque_base::const_iterator const_iterator; \
00082 explicit deque(const allocator_type& a = allocator_type()) : deque_base(a) {} \
00083 template<typename InputIterator> \
00084 deque(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
00085 : deque_base(first, last, a) {} \
00086 deque(const deque& c) : deque_base(c) {} \
00087 explicit deque(size_type num, const value_type& val = value_type()) : deque_base(num, val) {} \
00088 deque(iterator start, iterator end) : deque_base(start, end) {} \
00089 deque& operator=(const deque& x) { \
00090 deque_base::operator=(x); \
00091 return *this; \
00092 }
00093
00094 template<typename T>
00095 class deque<T,EIGEN_ALIGNED_ALLOCATOR<T> >
00096 : public deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00097 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
00098 {
00099 typedef deque<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00100 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > deque_base;
00101 EIGEN_STD_DEQUE_SPECIALIZATION_BODY
00102
00103 void resize(size_type new_size)
00104 { resize(new_size, T()); }
00105
00106 #if defined(_DEQUE_)
00107
00108 void resize(size_type new_size, const value_type& x)
00109 {
00110 if (deque_base::size() < new_size)
00111 deque_base::_Insert_n(deque_base::end(), new_size - deque_base::size(), x);
00112 else if (new_size < deque_base::size())
00113 deque_base::erase(deque_base::begin() + new_size, deque_base::end());
00114 }
00115 void push_back(const value_type& x)
00116 { deque_base::push_back(x); }
00117 void push_front(const value_type& x)
00118 { deque_base::push_front(x); }
00119 using deque_base::insert;
00120 iterator insert(const_iterator position, const value_type& x)
00121 { return deque_base::insert(position,x); }
00122 void insert(const_iterator position, size_type new_size, const value_type& x)
00123 { deque_base::insert(position, new_size, x); }
00124 #elif defined(_GLIBCXX_DEQUE) && EIGEN_GNUC_AT_LEAST(4,2)
00125
00126 void resize(size_type new_size, const value_type& x)
00127 {
00128 if (new_size < deque_base::size())
00129 deque_base::_M_erase_at_end(this->_M_impl._M_start + new_size);
00130 else
00131 deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);
00132 }
00133 #else
00134
00135
00136 void resize(size_type new_size, const value_type& x)
00137 {
00138 if (new_size < deque_base::size())
00139 deque_base::erase(deque_base::begin() + new_size, deque_base::end());
00140 else if (new_size > deque_base::size())
00141 deque_base::insert(deque_base::end(), new_size - deque_base::size(), x);
00142 }
00143 #endif
00144 };
00145 }
00146
00147 #endif // check whether specialization is actually required
00148
00149 #endif // EIGEN_STDDEQUE_H