11 #ifndef EIGEN_STDVECTOR_H
12 #define EIGEN_STDVECTOR_H
21 #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \
25 class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> > \
26 : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
28 typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \
30 typedef __VA_ARGS__ value_type; \
31 typedef vector_base::allocator_type allocator_type; \
32 typedef vector_base::size_type size_type; \
33 typedef vector_base::iterator iterator; \
34 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
35 template<typename InputIterator> \
36 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \
37 vector(const vector& c) : vector_base(c) {} \
38 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
39 vector(iterator start, iterator end) : vector_base(start, end) {} \
40 vector& operator=(const vector& x) { \
41 vector_base::operator=(x); \
49 #define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
51 typedef T value_type; \
52 typedef typename vector_base::allocator_type allocator_type; \
53 typedef typename vector_base::size_type size_type; \
54 typedef typename vector_base::iterator iterator; \
55 typedef typename vector_base::const_iterator const_iterator; \
56 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
57 template<typename InputIterator> \
58 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
59 : vector_base(first, last, a) {} \
60 vector(const vector& c) : vector_base(c) {} \
61 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
62 vector(iterator start, iterator end) : vector_base(start, end) {} \
63 vector& operator=(const vector& x) { \
64 vector_base::operator=(x); \
69 class vector<T,EIGEN_ALIGNED_ALLOCATOR<T> >
70 :
public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
71 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
73 typedef vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
74 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > vector_base;
75 EIGEN_STD_VECTOR_SPECIALIZATION_BODY
77 void resize(size_type new_size)
78 { resize(new_size, T()); }
82 void resize(size_type new_size,
const value_type& x)
84 if (vector_base::size() < new_size)
85 vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);
86 else if (new_size < vector_base::size())
87 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
89 void push_back(
const value_type& x)
90 { vector_base::push_back(x); }
91 using vector_base::insert;
92 iterator insert(const_iterator position,
const value_type& x)
93 {
return vector_base::insert(position,x); }
94 void insert(const_iterator position, size_type new_size,
const value_type& x)
95 { vector_base::insert(position, new_size, x); }
96 #elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))
99 void resize(size_type new_size,
const value_type& x)
101 vector_base::resize(new_size,x);
103 #elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
105 void resize(size_type new_size,
const value_type& x)
107 if (new_size < vector_base::size())
108 vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);
110 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
115 void resize(size_type new_size,
const value_type& x)
117 if (new_size < vector_base::size())
118 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
119 else if (new_size > vector_base::size())
120 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
126 #endif // EIGEN_STDVECTOR_H