StdList.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN_STDLIST_H
00011 #define EIGEN_STDLIST_H
00012 
00013 #include "details.h"
00014 
00015 // Define the explicit instantiation (e.g. necessary for the Intel compiler)
00016 #if defined(__INTEL_COMPILER) || defined(__GNUC__)
00017   #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...) template class std::list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> >;
00018 #else
00019   #define EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(...)
00020 #endif
00021 
00027 #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) \
00028 EIGEN_EXPLICIT_STL_LIST_INSTANTIATION(__VA_ARGS__) \
00029 namespace std \
00030 { \
00031   template<typename _Ay> \
00032   class list<__VA_ARGS__, _Ay>  \
00033     : public list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > \
00034   { \
00035     typedef list<__VA_ARGS__, EIGEN_ALIGNED_ALLOCATOR<__VA_ARGS__> > list_base; \
00036   public: \
00037     typedef __VA_ARGS__ value_type; \
00038     typedef typename list_base::allocator_type allocator_type; \
00039     typedef typename list_base::size_type size_type;  \
00040     typedef typename list_base::iterator iterator;  \
00041     explicit list(const allocator_type& a = allocator_type()) : list_base(a) {}  \
00042     template<typename InputIterator> \
00043     list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) : list_base(first, last, a) {} \
00044     list(const list& c) : list_base(c) {}  \
00045     explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \
00046     list(iterator start, iterator end) : list_base(start, end) {}  \
00047     list& operator=(const list& x) {  \
00048       list_base::operator=(x);  \
00049       return *this;  \
00050     } \
00051   }; \
00052 }
00053 
00054 // check whether we really need the std::vector specialization
00055 #if !(defined(_GLIBCXX_VECTOR) && (!EIGEN_GNUC_AT_LEAST(4,1))) /* Note that before gcc-4.1 we already have: std::list::resize(size_type,const T&). */
00056 
00057 namespace std
00058 {
00059 
00060 #define EIGEN_STD_LIST_SPECIALIZATION_BODY \
00061   public:  \
00062     typedef T value_type; \
00063     typedef typename list_base::allocator_type allocator_type; \
00064     typedef typename list_base::size_type size_type;  \
00065     typedef typename list_base::iterator iterator;  \
00066     typedef typename list_base::const_iterator const_iterator;  \
00067     explicit list(const allocator_type& a = allocator_type()) : list_base(a) {}  \
00068     template<typename InputIterator> \
00069     list(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
00070     : list_base(first, last, a) {} \
00071     list(const list& c) : list_base(c) {}  \
00072     explicit list(size_type num, const value_type& val = value_type()) : list_base(num, val) {} \
00073     list(iterator start, iterator end) : list_base(start, end) {}  \
00074     list& operator=(const list& x) {  \
00075     list_base::operator=(x);  \
00076     return *this; \
00077   }
00078 
00079   template<typename T>
00080   class list<T,EIGEN_ALIGNED_ALLOCATOR<T> >
00081     : public list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00082                   Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> >
00083   {
00084     typedef list<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T),
00085                  Eigen::aligned_allocator_indirection<EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T)> > list_base;
00086     EIGEN_STD_LIST_SPECIALIZATION_BODY
00087 
00088     void resize(size_type new_size)
00089     { resize(new_size, T()); }
00090 
00091     void resize(size_type new_size, const value_type& x)
00092     {
00093       if (list_base::size() < new_size)
00094         list_base::insert(list_base::end(), new_size - list_base::size(), x);
00095       else
00096         while (new_size < list_base::size()) list_base::pop_back();
00097     }
00098 
00099 #if defined(_LIST_)
00100     // workaround MSVC std::list implementation
00101     void push_back(const value_type& x)
00102     { list_base::push_back(x); } 
00103     using list_base::insert;  
00104     iterator insert(const_iterator position, const value_type& x)
00105     { return list_base::insert(position,x); }
00106     void insert(const_iterator position, size_type new_size, const value_type& x)
00107     { list_base::insert(position, new_size, x); }
00108 #endif
00109   };
00110 }
00111 
00112 #endif // check whether specialization is actually required
00113 
00114 #endif // EIGEN_STDLIST_H


turtlebot_exploration_3d
Author(s): Bona , Shawn
autogenerated on Thu Jun 6 2019 21:00:11