PageRenderTime 15ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Geometry_Eigen/Eigen/src/StlSupport/details.h

http://github.com/Akranar/daguerreo
C Header | 99 lines | 57 code | 14 blank | 28 comment | 0 complexity | 4bbbc75465fa9a225c138bfaa0eb312d MD5 | raw file
Possible License(s): AGPL-3.0, LGPL-2.1, LGPL-3.0, GPL-2.0
 1// This file is part of Eigen, a lightweight C++ template library
 2// for linear algebra.
 3//
 4// Copyright (C) 2009 Gael Guennebaud <gael.guennebaud@inria.fr>
 5// Copyright (C) 2009 Hauke Heibel <hauke.heibel@googlemail.com>
 6//
 7// Eigen is free software; you can redistribute it and/or
 8// modify it under the terms of the GNU Lesser General Public
 9// License as published by the Free Software Foundation; either
10// version 3 of the License, or (at your option) any later version.
11//
12// Alternatively, you can redistribute it and/or
13// modify it under the terms of the GNU General Public License as
14// published by the Free Software Foundation; either version 2 of
15// the License, or (at your option) any later version.
16//
17// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
18// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
20// GNU General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public
23// License and a copy of the GNU General Public License along with
24// Eigen. If not, see <http://www.gnu.org/licenses/>.
25
26#ifndef EIGEN_STL_DETAILS_H
27#define EIGEN_STL_DETAILS_H
28
29#ifndef EIGEN_ALIGNED_ALLOCATOR
30  #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator
31#endif
32
33namespace Eigen {
34
35  // This one is needed to prevent reimplementing the whole std::vector.
36  template <class T>
37  class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T>
38  {
39  public:
40    typedef size_t    size_type;
41    typedef ptrdiff_t difference_type;
42    typedef T*        pointer;
43    typedef const T*  const_pointer;
44    typedef T&        reference;
45    typedef const T&  const_reference;
46    typedef T         value_type;
47
48    template<class U>
49    struct rebind
50    {
51      typedef aligned_allocator_indirection<U> other;
52    };
53
54    aligned_allocator_indirection() {}
55    aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR<T>() {}
56    aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<T>& ) {}
57    template<class U>
58    aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) {}
59    template<class U>
60    aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<U>& ) {}
61    ~aligned_allocator_indirection() {}
62  };
63
64#ifdef _MSC_VER
65
66  // sometimes, MSVC detects, at compile time, that the argument x
67  // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
68  // even if this function is never called. Whence this little wrapper.
69#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \
70  typename Eigen::internal::conditional< \
71    Eigen::internal::is_arithmetic<T>::value, \
72    T, \
73    Eigen::internal::workaround_msvc_stl_support<T> \
74  >::type
75
76  namespace internal {
77  template<typename T> struct workaround_msvc_stl_support : public T
78  {
79    inline workaround_msvc_stl_support() : T() {}
80    inline workaround_msvc_stl_support(const T& other) : T(other) {}
81    inline operator T& () { return *static_cast<T*>(this); }
82    inline operator const T& () const { return *static_cast<const T*>(this); }
83    template<typename OtherT>
84    inline T& operator=(const OtherT& other)
85    { T::operator=(other); return *this; }
86    inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other)
87    { T::operator=(other); return *this; }
88  };
89  }
90
91#else
92
93#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T
94
95#endif
96
97}
98
99#endif // EIGEN_STL_DETAILS_H