details.h
Go to the documentation of this file.
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 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_STL_DETAILS_H
12 #define EIGEN_STL_DETAILS_H
13 
14 #ifndef EIGEN_ALIGNED_ALLOCATOR
15  #define EIGEN_ALIGNED_ALLOCATOR Eigen::aligned_allocator
16 #endif
17 
18 namespace Eigen {
19 
20  // This one is needed to prevent reimplementing the whole std::vector.
21  template <class T>
23  {
24  public:
25  typedef std::size_t size_type;
26  typedef std::ptrdiff_t difference_type;
27  typedef T* pointer;
28  typedef const T* const_pointer;
29  typedef T& reference;
30  typedef const T& const_reference;
31  typedef T value_type;
32 
33  template<class U>
34  struct rebind
35  {
37  };
38 
42  template<class U>
44  template<class U>
47  };
48 
49 #if EIGEN_COMP_MSVC
50 
51  // sometimes, MSVC detects, at compile time, that the argument x
52  // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
53  // even if this function is never called. Whence this little wrapper.
54 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \
55  std::conditional_t<Eigen::internal::is_arithmetic<T>::value, T, Eigen::internal::workaround_msvc_stl_support<T> >
56 
57  namespace internal {
58  template<typename T> struct workaround_msvc_stl_support : public T
59  {
60  inline workaround_msvc_stl_support() : T() {}
61  inline workaround_msvc_stl_support(const T& other) : T(other) {}
62  inline operator T& () { return *static_cast<T*>(this); }
63  inline operator const T& () const { return *static_cast<const T*>(this); }
64  template<typename OtherT>
65  inline T& operator=(const OtherT& other)
66  { T::operator=(other); return *this; }
67  inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other)
68  { T::operator=(other); return *this; }
69  };
70  }
71 
72 #else
73 
74 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T
75 
76 #endif
77 
78 }
79 
80 #endif // EIGEN_STL_DETAILS_H
aligned_allocator_indirection(const aligned_allocator_indirection< U > &)
Definition: details.h:43
aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR< U > &)
Definition: details.h:45
aligned_allocator_indirection(const aligned_allocator_indirection &)
Definition: details.h:40
aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR< T > &)
Definition: details.h:41
: InteropHeaders
Definition: Core:139
aligned_allocator_indirection< U > other
Definition: details.h:36