details.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 Gael Guennebaud <gael.guennebaud@inria.fr>
00005 // Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_STL_DETAILS_H
00012 #define EIGEN_STL_DETAILS_H
00013 
00014 #ifndef EIGEN_ALIGNED_ALLOCATOR
00015   #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator
00016 #endif
00017 
00018 namespace Eigen {
00019 
00020   // This one is needed to prevent reimplementing the whole std::vector.
00021   template <class T>
00022   class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T>
00023   {
00024   public:
00025     typedef size_t    size_type;
00026     typedef ptrdiff_t difference_type;
00027     typedef T*        pointer;
00028     typedef const T*  const_pointer;
00029     typedef T&        reference;
00030     typedef const T&  const_reference;
00031     typedef T         value_type;
00032 
00033     template<class U>
00034     struct rebind
00035     {
00036       typedef aligned_allocator_indirection<U> other;
00037     };
00038 
00039     aligned_allocator_indirection() {}
00040     aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR<T>() {}
00041     aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<T>& ) {}
00042     template<class U>
00043     aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) {}
00044     template<class U>
00045     aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<U>& ) {}
00046     ~aligned_allocator_indirection() {}
00047   };
00048 
00049 #ifdef _MSC_VER
00050 
00051   // sometimes, MSVC detects, at compile time, that the argument x
00052   // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
00053   // even if this function is never called. Whence this little wrapper.
00054 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \
00055   typename Eigen::internal::conditional< \
00056     Eigen::internal::is_arithmetic<T>::value, \
00057     T, \
00058     Eigen::internal::workaround_msvc_stl_support<T> \
00059   >::type
00060 
00061   namespace internal {
00062   template<typename T> struct workaround_msvc_stl_support : public T
00063   {
00064     inline workaround_msvc_stl_support() : T() {}
00065     inline workaround_msvc_stl_support(const T& other) : T(other) {}
00066     inline operator T& () { return *static_cast<T*>(this); }
00067     inline operator const T& () const { return *static_cast<const T*>(this); }
00068     template<typename OtherT>
00069     inline T& operator=(const OtherT& other)
00070     { T::operator=(other); return *this; }
00071     inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other)
00072     { T::operator=(other); return *this; }
00073   };
00074   }
00075 
00076 #else
00077 
00078 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T
00079 
00080 #endif
00081 
00082 }
00083 
00084 #endif // EIGEN_STL_DETAILS_H


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:58:05