From 19f02c76157bc98c232d3edaa1a4649243e99a31 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Sat, 25 Jan 2025 19:38:01 +0200 Subject: [PATCH] Add array_data_test_cx.cpp --- test/Jamfile.v2 | 1 + test/array_data_test_cx.cpp | 39 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 test/array_data_test_cx.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index fa88cbe6..d940e561 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -51,6 +51,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_size_test_cx.cpp ; # diff --git a/test/array_data_test_cx.cpp b/test/array_data_test_cx.cpp new file mode 100644 index 00000000..4b4e0f5a --- /dev/null +++ b/test/array_data_test_cx.cpp @@ -0,0 +1,39 @@ +// 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") + +#else + +#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__) + +template void test1() +{ + constexpr boost::array a = {}; + STATIC_ASSERT( a.data() == a.elems ); +} + +template void test2() +{ + constexpr boost::array a = {}; + STATIC_ASSERT( a.data() == 0 ); +} + +int main() +{ + test1(); + test1(); + + test2(); +} + +#endif