mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Remove pre-C++14 workarounds from unsupported/ tensor code
libeigen/eigen!2218 Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
@@ -231,37 +231,20 @@ template <typename T, std::size_t N>
|
||||
using array = std::array<T, N>;
|
||||
|
||||
namespace internal {
|
||||
/* std::get is only constexpr in C++14, not yet in C++11
|
||||
* - libstdc++ from version 4.7 onwards has it nevertheless,
|
||||
* so use that
|
||||
* - libstdc++ older versions: use _M_instance directly
|
||||
* - libc++ all versions so far: use __elems_ directly
|
||||
* - all other libs: use std::get to be portable, but
|
||||
* this may not be constexpr
|
||||
*/
|
||||
#if defined(__GLIBCXX__) && __GLIBCXX__ < 20120322
|
||||
#define STD_GET_ARR_HACK a._M_instance[I_]
|
||||
#elif defined(_LIBCPP_VERSION)
|
||||
#define STD_GET_ARR_HACK a.__elems_[I_]
|
||||
#else
|
||||
#define STD_GET_ARR_HACK std::template get<I_, T, N>(a)
|
||||
#endif
|
||||
|
||||
template <std::size_t I_, class T, std::size_t N>
|
||||
constexpr T& array_get(std::array<T, N>& a) {
|
||||
return (T&)STD_GET_ARR_HACK;
|
||||
return std::get<I_>(a);
|
||||
}
|
||||
template <std::size_t I_, class T, std::size_t N>
|
||||
constexpr T&& array_get(std::array<T, N>&& a) {
|
||||
return (T&&)STD_GET_ARR_HACK;
|
||||
return std::get<I_>(std::move(a));
|
||||
}
|
||||
template <std::size_t I_, class T, std::size_t N>
|
||||
constexpr T const& array_get(std::array<T, N> const& a) {
|
||||
return (T const&)STD_GET_ARR_HACK;
|
||||
return std::get<I_>(a);
|
||||
}
|
||||
|
||||
#undef STD_GET_ARR_HACK
|
||||
|
||||
} // end namespace internal
|
||||
} // end namespace Eigen
|
||||
|
||||
|
||||
Reference in New Issue
Block a user