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_STDVECTOR_H
00027 #define EIGEN_STDVECTOR_H
00028
00029 #include "Eigen/src/StlSupport/details.h"
00030
00031
00032 #if defined(__INTEL_COMPILER) || defined(__GNUC__)
00033 #define EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(...) template class std::vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> >;
00034 #else
00035 #define EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(...)
00036 #endif
00037
00043 #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \
00044 EIGEN_EXPLICIT_STL_VECTOR_INSTANTIATION(__VA_ARGS__) \
00045 namespace std \
00046 { \
00047 template<typename _Ay> \
00048 class vector<__VA_ARGS__, _Ay> \
00049 : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
00050 { \
00051 typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \
00052 public: \
00053 typedef __VA_ARGS__ value_type; \
00054 typedef typename vector_base::allocator_type allocator_type; \
00055 typedef typename vector_base::size_type size_type; \
00056 typedef typename vector_base::iterator iterator; \
00057 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
00058 template<typename InputIterator> \
00059 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \
00060 vector(const vector& c) : vector_base(c) {} \
00061 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
00062 vector(iterator start, iterator end) : vector_base(start, end) {} \
00063 vector& operator=(const vector& x) { \
00064 vector_base::operator=(x); \
00065 return *this; \
00066 } \
00067 }; \
00068 }
00069
00070 namespace std {
00071
00072 #define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
00073 public: \
00074 typedef T value_type; \
00075 typedef typename vector_base::allocator_type allocator_type; \
00076 typedef typename vector_base::size_type size_type; \
00077 typedef typename vector_base::iterator iterator; \
00078 typedef typename vector_base::const_iterator const_iterator; \
00079 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
00080 template<typename InputIterator> \
00081 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
00082 : vector_base(first, last, a) {} \
00083 vector(const vector& c) : vector_base(c) {} \
00084 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
00085 vector(iterator start, iterator end) : vector_base(start, end) {} \
00086 vector& operator=(const vector& x) { \
00087 vector_base::operator=(x); \
00088 return *this; \
00089 }
00090
00091 template<typename T>
00092 class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >
00093 : public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00094 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
00095 {
00096 typedef vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00097 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > vector_base;
00098 EIGEN_STD_VECTOR_SPECIALIZATION_BODY
00099
00100 void resize(size_type new_size)
00101 { resize(new_size, T()); }
00102
00103 #if defined(_VECTOR_)
00104
00105 void resize(size_type new_size, const value_type& x)
00106 {
00107 if (vector_base::size() < new_size)
00108 vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);
00109 else if (new_size < vector_base::size())
00110 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
00111 }
00112 void push_back(const value_type& x)
00113 { vector_base::push_back(x); }
00114 using vector_base::insert;
00115 iterator insert(const_iterator position, const value_type& x)
00116 { return vector_base::insert(position,x); }
00117 void insert(const_iterator position, size_type new_size, const value_type& x)
00118 { vector_base::insert(position, new_size, x); }
00119 #elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))
00120
00121
00122 void resize(size_type new_size, const value_type& x)
00123 {
00124 vector_base::resize(new_size,x);
00125 }
00126 #elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
00127
00128 void resize(size_type new_size, const value_type& x)
00129 {
00130 if (new_size < vector_base::size())
00131 vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);
00132 else
00133 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
00134 }
00135 #else
00136
00137
00138 void resize(size_type new_size, const value_type& x)
00139 {
00140 if (new_size < vector_base::size())
00141 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
00142 else if (new_size > vector_base::size())
00143 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
00144 }
00145 #endif
00146 };
00147 }
00148
00149 #endif // EIGEN_STDVECTOR_H