Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
 
Loading...
Searching...
No Matches
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#include <cstddef>
18
19namespace Eigen {
20
21 // This one is needed to prevent reimplementing the whole std::vector.
22 template <class T>
23 class aligned_allocator_indirection : public EIGEN_ALIGNED_ALLOCATOR<T>
24 {
25 public:
26 typedef std::size_t size_type;
27 typedef std::ptrdiff_t difference_type;
28 typedef T* pointer;
29 typedef const T* const_pointer;
30 typedef T& reference;
31 typedef const T& const_reference;
32 typedef T value_type;
33
34 template<class U>
35 struct rebind
36 {
37 typedef aligned_allocator_indirection<U> other;
38 };
39
40 aligned_allocator_indirection() {}
41 aligned_allocator_indirection(const aligned_allocator_indirection& ) : EIGEN_ALIGNED_ALLOCATOR<T>() {}
42 aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<T>& ) {}
43 template<class U>
44 aligned_allocator_indirection(const aligned_allocator_indirection<U>& ) {}
45 template<class U>
46 aligned_allocator_indirection(const EIGEN_ALIGNED_ALLOCATOR<U>& ) {}
47 ~aligned_allocator_indirection() {}
48 };
49
50#if EIGEN_COMP_MSVC
51
52 // sometimes, MSVC detects, at compile time, that the argument x
53 // in std::vector::resize(size_t s,T x) won't be aligned and generate an error
54 // even if this function is never called. Whence this little wrapper.
55#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) \
56 typename Eigen::internal::conditional< \
57 Eigen::internal::is_arithmetic<T>::value, \
58 T, \
59 Eigen::internal::workaround_msvc_stl_support<T> \
60 >::type
61
62 namespace internal {
63 template<typename T> struct workaround_msvc_stl_support : public T
64 {
65 inline workaround_msvc_stl_support() : T() {}
66 inline workaround_msvc_stl_support(const T& other) : T(other) {}
67 inline operator T& () { return *static_cast<T*>(this); }
68 inline operator const T& () const { return *static_cast<const T*>(this); }
69 template<typename OtherT>
70 inline T& operator=(const OtherT& other)
71 { T::operator=(other); return *this; }
72 inline workaround_msvc_stl_support& operator=(const workaround_msvc_stl_support& other)
73 { T::operator=(other); return *this; }
74 };
75 }
76
77#else
78
79#define EIGEN_WORKAROUND_MSVC_STL_SUPPORT(T) T
80
81#endif
82
83}
84
85#endif // EIGEN_STL_DETAILS_H
Namespace containing all symbols from the Eigen library.
Definition Core:141