diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 02c6464..58f60aa 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -104,6 +104,7 @@ compile array_fill_test_cx.cpp ; compile array_eq_test_cx.cpp ; compile array_lt_test_cx.cpp ; compile array_thw_test_cx.cpp ; +compile to_array_test_cx.cpp ; # diff --git a/test/to_array_test_cx.cpp b/test/to_array_test_cx.cpp new file mode 100644 index 0000000..e7f32c7 --- /dev/null +++ b/test/to_array_test_cx.cpp @@ -0,0 +1,32 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +#if defined(BOOST_NO_CXX14_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +int main() +{ + { + constexpr int a[] = { 1, 2, 3, 4 }; + constexpr boost::array b = boost::to_array( a ); + + STATIC_ASSERT( b[0] == 1 ); + STATIC_ASSERT( b[1] == 2 ); + STATIC_ASSERT( b[2] == 3 ); + STATIC_ASSERT( b[3] == 4 ); + } +} + +#endif