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