$darkmode
Eigen  5.0.1-dev
details.h
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>
22 class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T> {
23  public:
24  typedef std::size_t size_type;
25  typedef std::ptrdiff_t difference_type;
26  typedef T* pointer;
27  typedef const T* const_pointer;
28  typedef T& reference;
29  typedef const T& const_reference;
30  typedef T value_type;
31 
32  template <class U>
33  struct rebind {
34  typedef aligned_allocator_indirection<U> other;
35  };
36 
37  aligned_allocator_indirection() {}
38  aligned_allocator_indirection(const aligned_allocator_indirection&) : EIGEN_ALIGNED_ALLOCATOR<T>() {}
39  aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<T>&) {}
40  template <class U>
41  aligned_allocator_indirection(const aligned_allocator_indirection<U>&) {}
42  template <class U>
43  aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<U>&) {}
44  ~aligned_allocator_indirection() {}
45 };
46 
47 #if EIGEN_COMP_MSVC
48 
49 // sometimes, MSVC detects, at compile time, that the argument x
50 // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
51 // even if this function is never called. Whence this little wrapper.
52 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \
53  std::conditional_t<Eigen::internal::is_arithmetic<T>::value, T, Eigen::internal::workaround_msvc_stl_support<T> >
54 
55 namespace internal {
56 template <typename T>
57 struct workaround_msvc_stl_support : public T {
58  inline workaround_msvc_stl_support() : T() {}
59  inline workaround_msvc_stl_support(const T& other) : T(other) {}
60  inline operator T&() { return *static_cast<T*>(this); }
61  inline operator const T&() const { return *static_cast<const T*>(this); }
62  template <typename OtherT>
63  inline T& operator=(const OtherT& other) {
64  T::operator=(other);
65  return *this;
66  }
67  inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other) {
68  T::operator=(other);
69  return *this;
70  }
71 };
72 } // namespace internal
73 
74 #else
75 
76 #define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T
77 
78 #endif
79 
80 } // namespace Eigen
81 
82 #endif // EIGEN_STL_DETAILS_H
Namespace containing all symbols from the Eigen library.
Definition: B01_Experimental.dox:1