10 #ifndef EIGEN_EMULATE_ARRAY_H 11 #define EIGEN_EMULATE_ARRAY_H 18 #if __cplusplus <= 199711L || defined(__CUDACC__) || defined(EIGEN_AVOID_STL_ARRAY) 21 template <
typename T,
size_t n>
class array {
24 EIGEN_STRONG_INLINE T& operator[] (
size_t index) {
return values[index]; }
26 EIGEN_STRONG_INLINE
const T& operator[] (
size_t index)
const {
return values[index]; }
28 EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
29 static std::size_t size() {
return n; }
34 EIGEN_STRONG_INLINE array() { }
35 explicit EIGEN_DEVICE_FUNC
36 EIGEN_STRONG_INLINE array(
const T& v) {
37 EIGEN_STATIC_ASSERT(n==1, YOU_MADE_A_PROGRAMMING_MISTAKE)
41 EIGEN_STRONG_INLINE array(const T& v1, const T& v2) {
42 EIGEN_STATIC_ASSERT(n==2, YOU_MADE_A_PROGRAMMING_MISTAKE)
47 EIGEN_STRONG_INLINE array(const T& v1, const T& v2, const T& v3) {
48 EIGEN_STATIC_ASSERT(n==3, YOU_MADE_A_PROGRAMMING_MISTAKE)
54 EIGEN_STRONG_INLINE array(const T& v1, const T& v2, const T& v3,
56 EIGEN_STATIC_ASSERT(n==4, YOU_MADE_A_PROGRAMMING_MISTAKE)
63 EIGEN_STRONG_INLINE array(const T& v1, const T& v2, const T& v3, const T& v4,
65 EIGEN_STATIC_ASSERT(n==5, YOU_MADE_A_PROGRAMMING_MISTAKE)
73 EIGEN_STRONG_INLINE array(const T& v1, const T& v2, const T& v3, const T& v4,
74 const T& v5, const T& v6) {
75 EIGEN_STATIC_ASSERT(n==6, YOU_MADE_A_PROGRAMMING_MISTAKE)
84 EIGEN_STRONG_INLINE array(const T& v1, const T& v2, const T& v3, const T& v4,
85 const T& v5, const T& v6, const T& v7) {
86 EIGEN_STATIC_ASSERT(n==7, YOU_MADE_A_PROGRAMMING_MISTAKE)
96 EIGEN_STRONG_INLINE array(
97 const T& v1, const T& v2, const T& v3, const T& v4,
98 const T& v5, const T& v6, const T& v7, const T& v8) {
99 EIGEN_STATIC_ASSERT(n==8, YOU_MADE_A_PROGRAMMING_MISTAKE)
110 #ifdef EIGEN_HAS_VARIADIC_TEMPLATES 112 EIGEN_STRONG_INLINE array(std::initializer_list<T> l) {
113 eigen_assert(l.size() == n);
114 internal::smart_copy(l.begin(), l.end(), values);
121 template <
typename T>
class array<T, 0> {
124 EIGEN_STRONG_INLINE T& operator[] (
size_t) {
125 eigen_assert(
false &&
"Can't index a zero size array");
126 return *
static_cast<T*
>(NULL);
130 EIGEN_STRONG_INLINE
const T& operator[] (
size_t)
const {
131 eigen_assert(
false &&
"Can't index a zero size array");
132 return *
static_cast<const T*
>(NULL);
135 static EIGEN_ALWAYS_INLINE std::size_t size() {
return 0; }
138 EIGEN_STRONG_INLINE array() { }
140 #ifdef EIGEN_HAS_VARIADIC_TEMPLATES 141 array(std::initializer_list<T> l) {
142 eigen_assert(l.size() == 0);
148 template<std::
size_t I,
class T, std::
size_t N>
149 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T& array_get(array<T,N>& a) {
152 template<std::
size_t I,
class T, std::
size_t N>
153 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
const T& array_get(
const array<T,N>& a) {
157 template <
typename T>
struct array_size;
158 template<
class T, std::
size_t N>
struct array_size<array<T,N> > {
159 static const size_t value = N;
161 template <
typename T>
struct array_size;
162 template<
class T, std::
size_t N>
struct array_size<array<T,N>& > {
163 static const size_t value = N;
165 template <
typename T>
struct array_size;
166 template<
class T, std::
size_t N>
struct array_size<const array<T,N> > {
167 static const size_t value = N;
169 template <
typename T>
struct array_size;
170 template<
class T, std::
size_t N>
struct array_size<const array<T,N>& > {
171 static const size_t value = N;
183 template <
typename T, std::
size_t N>
using array = std::array<T, N>;
194 #if defined(__GLIBCXX__) && __GLIBCXX__ < 20120322 195 #define STD_GET_ARR_HACK a._M_instance[I] 196 #elif defined(_LIBCPP_VERSION) 197 #define STD_GET_ARR_HACK a.__elems_[I] 199 #define STD_GET_ARR_HACK std::template get<I, T, N>(a) 202 template<std::
size_t I,
class T, std::
size_t N> constexpr
inline T& array_get(std::array<T,N>& a) {
return (T&) STD_GET_ARR_HACK; }
203 template<std::
size_t I,
class T, std::
size_t N> constexpr
inline T&& array_get(std::array<T,N>&& a) {
return (T&&) STD_GET_ARR_HACK; }
204 template<std::
size_t I,
class T, std::
size_t N> constexpr
inline T
const& array_get(std::array<T,N>
const& a) {
return (T
const&) STD_GET_ARR_HACK; }
206 #undef STD_GET_ARR_HACK 208 template <
typename T>
struct array_size;
209 template<
class T, std::
size_t N>
struct array_size<const std::array<T,N> > {
210 static const size_t value = N;
212 template <
typename T>
struct array_size;
213 template<
class T, std::
size_t N>
struct array_size<std::array<T,N> > {
214 static const size_t value = N;
225 #endif // EIGEN_EMULATE_ARRAY_H Namespace containing all symbols from the Eigen library.
Definition: CXX11Meta.h:13