diff options
author | 2015-10-23 10:20:51 -0700 | |
---|---|---|
committer | 2015-10-23 10:20:51 -0700 | |
commit | 57857775b461b020c16f2bbeb130d6b1863d951c (patch) | |
tree | 28d42daaeca3ffb40e2593b9d2872873d9c629e2 /unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h | |
parent | c40c2ceb27d8a9dabadcbf46a4e3161f3189992f (diff) |
Added support for arrays of size 0
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h')
-rw-r--r-- | unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h b/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h index 0ae638fb9..ecd1bddf1 100644 --- a/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h +++ b/unsupported/Eigen/CXX11/src/Core/util/EmulateCXX11Meta.h @@ -113,6 +113,35 @@ template <typename T, size_t n> class array { }; +// Specialize array for zero size +template <typename T> class array<T, 0> { + public: + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE T& operator[] (size_t) { + eigen_assert(false && "Can't index a zero size array"); + return *static_cast<T*>(NULL); + } + + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE const T& operator[] (size_t) const { + eigen_assert(false && "Can't index a zero size array"); + return *static_cast<const T*>(NULL); + } + + static EIGEN_ALWAYS_INLINE std::size_t size() { return 0; } + + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE array() { } + +#ifdef EIGEN_HAS_VARIADIC_TEMPLATES + array(std::initializer_list<T> l) { + eigen_assert(l.size() == 0); + } +#endif +}; + + + namespace internal { /** \internal @@ -279,7 +308,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE typename NList::HeadType::type array_prod( return arg_prod<NList>::value; } -template<std::size_t n, typename t> +template<typename t, std::size_t n> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE t array_prod(const array<t, n>& a) { t prod = 1; for (size_t i = 0; i < n; ++i) { prod *= a[i]; } |