Add to_array_test_cx.cpp

This commit is contained in:
Peter Dimov
2025-02-23 20:59:49 +02:00
parent ffbced7a17
commit e97dc53868
2 changed files with 33 additions and 0 deletions

View File

@ -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 ;
#

32
test/to_array_test_cx.cpp Normal file
View File

@ -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 <boost/array.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef>
#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<int, 4> 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