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 #ifndef EIGEN_STDLIST_H
00026 #define EIGEN_STDLIST_H
00027
00028 #include "Eigen/src/StlSupport/details.h"
00029
00030
00031 #if defined(__INTEL_COMPILER) || defined(__GNUC__)
00032 #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...) template class std::list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> >;
00033 #else
00034 #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...)
00035 #endif
00036
00042 #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) \
00043 EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(__VA_ARGS__) \
00044 namespace std \
00045 { \
00046 template<typename _Ay> \
00047 class list<__VA_ARGS__, _Ay> \
00048 : public list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
00049 { \
00050 typedef list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > list_base; \
00051 public: \
00052 typedef __VA_ARGS__ value_type; \
00053 typedef typename list_base::allocator_type allocator_type; \
00054 typedef typename list_base::size_type size_type; \
00055 typedef typename list_base::iterator iterator; \
00056 explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \
00057 template<typename InputIterator> \
00058 list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \
00059 list(const list& c) : list_base(c) {} \
00060 explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \
00061 list(iterator start, iterator end) : list_base(start, end) {} \
00062 list& operator=(const list& x) { \
00063 list_base::operator=(x); \
00064 return *this; \
00065 } \
00066 }; \
00067 }
00068
00069
00070 #if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1)))
00071
00072 namespace std
00073 {
00074
00075 #define EIGEN_STD_LIST_SPECIALIZATION_BODY \
00076 public: \
00077 typedef T value_type; \
00078 typedef typename list_base::allocator_type allocator_type; \
00079 typedef typename list_base::size_type size_type; \
00080 typedef typename list_base::iterator iterator; \
00081 typedef typename list_base::const_iterator const_iterator; \
00082 explicit list(const allocator_type& a = allocator_type()) : list_base(a) {} \
00083 template<typename InputIterator> \
00084 list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
00085 : list_base(first, last, a) {} \
00086 list(const list& c) : list_base(c) {} \
00087 explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \
00088 list(iterator start, iterator end) : list_base(start, end) {} \
00089 list& operator=(const list& x) { \
00090 list_base::operator=(x); \
00091 return *this; \
00092 }
00093
00094 template<typename T>
00095 class list<T,EIGEN_ALIGNED_ALLOCATOR<T> >
00096 : public list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00097 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
00098 {
00099 typedef list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00100 Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > list_base;
00101 EIGEN_STD_LIST_SPECIALIZATION_BODY
00102
00103 void resize(size_type new_size)
00104 { resize(new_size, T()); }
00105
00106 void resize(size_type new_size, const value_type& x)
00107 {
00108 if (list_base::size() < new_size)
00109 list_base::insert(list_base::end(), new_size - list_base::size(), x);
00110 else
00111 while (new_size < list_base::size()) list_base::pop_back();
00112 }
00113
00114 #if defined(_LIST_)
00115
00116 void push_back(const value_type& x)
00117 { list_base::push_back(x); }
00118 using list_base::insert;
00119 iterator insert(const_iterator position, const value_type& x)
00120 { return list_base::insert(position,x); }
00121 void insert(const_iterator position, size_type new_size, const value_type& x)
00122 { list_base::insert(position, new_size, x); }
00123 #endif
00124 };
00125 }
00126
00127 #endif // check whether specialization is actually required
00128
00129 #endif // EIGEN_STDLIST_H