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  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 {
35  };
36 
40  template <class U>
42  template <class U>
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
Definition: details.h:22
T * pointer
Definition: details.h:26
aligned_allocator_indirection(const aligned_allocator_indirection< U > &)
Definition: details.h:41
std::ptrdiff_t difference_type
Definition: details.h:25
~aligned_allocator_indirection()
Definition: details.h:44
const T * const_pointer
Definition: details.h:27
T & reference
Definition: details.h:28
T value_type
Definition: details.h:30
aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR< U > &)
Definition: details.h:43
std::size_t size_type
Definition: details.h:24
aligned_allocator_indirection(const aligned_allocator_indirection &)
Definition: details.h:38
aligned_allocator_indirection()
Definition: details.h:37
aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR< T > &)
Definition: details.h:39
const T & const_reference
Definition: details.h:29
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
Definition: Eigen_Colamd.h:49
aligned_allocator_indirection< U > other
Definition: details.h:34