From dd77b4ec70a4afe21b91fec72273afa55b4087ad Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Thu, 4 Nov 2021 12:15:14 +0100 Subject: [PATCH] First experiments --- include/etl/array.h | 9 +++++++++ test/test_array.cpp | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/include/etl/array.h b/include/etl/array.h index 5d26874d..584a69bc 100644 --- a/include/etl/array.h +++ b/include/etl/array.h @@ -561,6 +561,15 @@ namespace etl -> array && ...), T>, 1U + sizeof...(Ts)>; #endif +#if ETL_CPP11_SUPPORTED + template + constexpr auto make_array(T&&... t) + -> etl::array, sizeof...(T)> + { + return { { etl::forward(t)... } }; + } +#endif + //************************************************************************* /// Overloaded swap for etl::array ///\param lhs The first array. diff --git a/test/test_array.cpp b/test/test_array.cpp index 6e803bd9..ca4fd04d 100644 --- a/test/test_array.cpp +++ b/test/test_array.cpp @@ -644,5 +644,14 @@ namespace CHECK(data >= data); CHECK(!(lesser >= data)); } + + //************************************************************************* + TEST(test_make_array) + { + auto data = etl::make_array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); + + CHECK_EQUAL(5, data[5]); + } + }; }