1 #ifndef DUNE_COMMON_STD_MAKE_ARRAY_HH 2 #define DUNE_COMMON_STD_MAKE_ARRAY_HH 3 4 #include <array> 5 #include <type_traits> 6 7 #if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY 8 #include <experimental/array> 9 #endif 10 11 namespace Dune { 12 namespace Std { 13 14 #if DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY 15 16 /// \deprecated Use deduction guide of `std::array` or `std::to_array`. 17 using std::experimental::make_array; 18 19 #else // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY 20 21 //! Create and initialize an array 22 /** 23 * \note This method is a somewhat limited dune-specific version of 24 * make_array() as proposed for C++17 (see <a 25 * href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4391.html">N4391</a>, 26 * accepted <a 27 * href="https://botondballo.wordpress.com/2015/06/05/trip-report-c-standards-meeting-in-lenexa-may-2015/">May 28 * 2015</a>). The differences are that this version should 29 * never be used with expliclitly given template arguments, or 30 * with std::reference_wrapper<...> arguments, and we do not 31 * give a diagnostic when anyone happens to do that. 32 * 33 * \ingroup CxxUtilities 34 * \deprecated Use deduction guide of `std::array` or `std::to_array`. 35 */ 36 template <typename... Args> 37 std::array<typename std::common_type<Args...>::type, sizeof...(Args)> 38 make_array(const Args&... args) { 39 std::array<typename std::common_type<Args...>::type, sizeof...(Args)> 40 result = {{args...}}; 41 return result; 42 } 43 44 #endif // DUNE_HAVE_CXX_EXPERIMENTAL_MAKE_ARRAY 45 46 } 47 } 48 49 #endif 50