diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d940e561..58dc7613 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -52,6 +52,7 @@ run array_get_test.cpp ; compile array_init_test_cx.cpp ; compile array_copy_test_cx.cpp ; compile array_data_test_cx.cpp ; +compile array_iterator_test_cx.cpp ; compile array_size_test_cx.cpp ; # diff --git a/test/array_iterator_test_cx.cpp b/test/array_iterator_test_cx.cpp new file mode 100644 index 00000000..e1bdc85a --- /dev/null +++ b/test/array_iterator_test_cx.cpp @@ -0,0 +1,54 @@ +// 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_CXX11_CONSTEXPR) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined") + +#elif BOOST_WORKAROUND(BOOST_MSVC, < 1910) + +BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_MSVC < 1910") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {}; + + STATIC_ASSERT( a.begin() == a.data() ); + STATIC_ASSERT( a.end() == a.data() + N ); + + STATIC_ASSERT( a.cbegin() == a.data() ); + STATIC_ASSERT( a.cend() == a.data() + N ); +} + +template void test2() +{ + constexpr boost::array a = {}; + + // iterator access is not constexpr for boost::array + // it is for std::array, though, so we should change it + + STATIC_ASSERT( a.begin() == a.end() ); + STATIC_ASSERT( a.cbegin() == a.cend() ); +} + +int main() +{ + // test1(); + test1(); + test1(); + + // test2(); +} + +#endif