Skip to content

Commit e97dc53

Browse files
committed
Add to_array_test_cx.cpp
1 parent ffbced7 commit e97dc53

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

test/Jamfile.v2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ compile array_fill_test_cx.cpp ;
104104
compile array_eq_test_cx.cpp ;
105105
compile array_lt_test_cx.cpp ;
106106
compile array_thw_test_cx.cpp ;
107+
compile to_array_test_cx.cpp ;
107108

108109
#
109110

test/to_array_test_cx.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2025 Peter Dimov
2+
// Distributed under the Boost Software License, Version 1.0.
3+
// https://www.boost.org/LICENSE_1_0.txt
4+
5+
#include <boost/array.hpp>
6+
#include <boost/config.hpp>
7+
#include <boost/config/pragma_message.hpp>
8+
#include <boost/config/workaround.hpp>
9+
#include <cstddef>
10+
11+
#if defined(BOOST_NO_CXX14_CONSTEXPR)
12+
13+
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX14_CONSTEXPR is defined")
14+
15+
#else
16+
17+
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
18+
19+
int main()
20+
{
21+
{
22+
constexpr int a[] = { 1, 2, 3, 4 };
23+
constexpr boost::array<int, 4> b = boost::to_array( a );
24+
25+
STATIC_ASSERT( b[0] == 1 );
26+
STATIC_ASSERT( b[1] == 2 );
27+
STATIC_ASSERT( b[2] == 3 );
28+
STATIC_ASSERT( b[3] == 4 );
29+
}
30+
}
31+
32+
#endif

0 commit comments

Comments
 (0)