26 #ifndef EIGEN_STDVECTOR_H
27 #define EIGEN_STDVECTOR_H
36 #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) \
40 class vector<__VA_ARGS__, std::allocator<__VA_ARGS__> > \
41 : public vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
43 typedef vector<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > vector_base; \
45 typedef __VA_ARGS__ value_type; \
46 typedef vector_base::allocator_type allocator_type; \
47 typedef vector_base::size_type size_type; \
48 typedef vector_base::iterator iterator; \
49 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
50 template<typename InputIterator> \
51 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : vector_base(first, last, a) {} \
52 vector(const vector& c) : vector_base(c) {} \
53 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
54 vector(iterator start, iterator end) : vector_base(start, end) {} \
55 vector& operator=(const vector& x) { \
56 vector_base::operator=(x); \
64 #define EIGEN_STD_VECTOR_SPECIALIZATION_BODY \
66 typedef T value_type; \
67 typedef typename vector_base::allocator_type allocator_type; \
68 typedef typename vector_base::size_type size_type; \
69 typedef typename vector_base::iterator iterator; \
70 typedef typename vector_base::const_iterator const_iterator; \
71 explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
72 template<typename InputIterator> \
73 vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
74 : vector_base(first, last, a) {} \
75 vector(const vector& c) : vector_base(c) {} \
76 explicit vector(size_type num, const value_type& val = value_type()) : vector_base(num, val) {} \
77 vector(iterator start, iterator end) : vector_base(start, end) {} \
78 vector& operator=(const vector& x) { \
79 vector_base::operator=(x); \
85 :
public vector<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
86 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
92 void resize(size_type new_size)
93 { resize(new_size, T()); }
97 void resize(size_type new_size,
const value_type& x)
99 if (vector_base::size() < new_size)
100 vector_base::_Insert_n(vector_base::end(), new_size - vector_base::size(), x);
101 else if (new_size < vector_base::size())
102 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
104 void push_back(
const value_type& x)
105 { vector_base::push_back(x); }
106 using vector_base::insert;
107 iterator insert(const_iterator position,
const value_type& x)
108 {
return vector_base::insert(position,x); }
109 void insert(const_iterator position, size_type new_size,
const value_type& x)
110 { vector_base::insert(position, new_size, x); }
111 #elif defined(_GLIBCXX_VECTOR) && (!(EIGEN_GNUC_AT_LEAST(4,1)))
114 void resize(size_type new_size,
const value_type& x)
116 vector_base::resize(new_size,x);
118 #elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,2)
120 void resize(size_type new_size,
const value_type& x)
122 if (new_size < vector_base::size())
123 vector_base::_M_erase_at_end(this->_M_impl._M_start + new_size);
125 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
130 void resize(size_type new_size,
const value_type& x)
132 if (new_size < vector_base::size())
133 vector_base::erase(vector_base::begin() + new_size, vector_base::end());
134 else if (new_size > vector_base::size())
135 vector_base::insert(vector_base::end(), new_size - vector_base::size(), x);
141 #endif // EIGEN_STDVECTOR_H