diff --git a/hpx/util/tuple.hpp b/hpx/util/tuple.hpp index 0eb07d0f26ef..a1c1e9b68e93 100644 --- a/hpx/util/tuple.hpp +++ b/hpx/util/tuple.hpp @@ -21,6 +21,10 @@ #include #include +#if defined(HPX_HAVE_CXX11_STD_ARRAY) +#include +#endif + #if defined(HPX_MSVC_WARNING_PRAGMA) #pragma warning(push) #pragma warning(disable: 4520) // multiple default constructors specified @@ -532,6 +536,13 @@ namespace hpx { namespace util : boost::integral_constant {}; +#if defined(HPX_HAVE_CXX11_STD_ARRAY) + template + struct tuple_size > + : boost::integral_constant + {}; +#endif + // template // class tuple_element template @@ -625,6 +636,26 @@ namespace hpx { namespace util } }; +#if defined(HPX_HAVE_CXX11_STD_ARRAY) + template + struct tuple_element > + { + typedef Type type; + + static HPX_CONSTEXPR HPX_HOST_DEVICE HPX_FORCEINLINE type& + get(std::array& tuple) noexcept + { + return tuple[I]; + } + + static HPX_CONSTEXPR HPX_HOST_DEVICE HPX_FORCEINLINE type const& + get(std::array const& tuple) noexcept + { + return tuple[I]; + } + }; +#endif + // 20.4.2.6, element access // template diff --git a/tests/unit/util/tuple.cpp b/tests/unit/util/tuple.cpp index d4b397d8dff3..d83cf799d876 100644 --- a/tests/unit/util/tuple.cpp +++ b/tests/unit/util/tuple.cpp @@ -9,6 +9,7 @@ // tuple_test_bench.cpp -------------------------------- +#include #include #include #include @@ -18,6 +19,10 @@ #include #include +#if defined(HPX_HAVE_CXX11_STD_ARRAY) +#include +#endif + // ---------------------------------------------------------------------------- // helpers // ---------------------------------------------------------------------------- @@ -189,6 +194,11 @@ void element_access_test() HPX_TEST((std::is_const >::type>::value)); +#if defined(HPX_HAVE_CXX11_STD_ARRAY) + HPX_TEST((std::is_same>::type, float>::value)); +#endif + dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables } @@ -377,6 +387,12 @@ void tuple_length_test() HPX_TEST(hpx::util::tuple_size::value == 3); HPX_TEST(hpx::util::tuple_size::value == 0); +#if defined(HPX_HAVE_CXX11_STD_ARRAY) + { + using t3 = std::array; + HPX_TEST(hpx::util::tuple_size::value == 4); + } +#endif } // ----------------------------------------------------------------------------