mirror of
https://github.com/boostorg/array.git
synced 2025-07-13 04:36:32 +02:00
Compare commits
5 Commits
feature/th
...
boost-1.88
Author | SHA1 | Date | |
---|---|---|---|
eee0d5bbc5 | |||
ec61272c1f | |||
e97dc53868 | |||
ffbced7a17 | |||
37289c5d92 |
@ -21,3 +21,4 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
* Removed local `hash_value` overload; `boost::hash` supports array-like types natively.
|
||||
* `array<T, 0>` can now be initialized with `= {{}}`.
|
||||
* Added `operator\<\=>`.
|
||||
* Added `to_array`.
|
||||
|
@ -42,6 +42,13 @@ namespace boost {
|
||||
constexpr T& get(array<T, N>&) noexcept;
|
||||
template<std::size_t Idx, typename T, std::size_t N>
|
||||
constexpr const T& get(const array<T, N>&) noexcept;
|
||||
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T const (&)[N] );
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T (&&)[N] );
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T const (&&)[N] );
|
||||
}
|
||||
```
|
||||
|
||||
@ -417,3 +424,29 @@ Mandates: :: `Idx < N`.
|
||||
Returns: :: `arr[Idx]`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Creation
|
||||
|
||||
```
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T const (&a)[N] );
|
||||
```
|
||||
[horizontal]
|
||||
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`.
|
||||
|
||||
```
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T (&&a)[N] );
|
||||
```
|
||||
[horizontal]
|
||||
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is moved from `std::move(a[i])`.
|
||||
|
||||
```
|
||||
template<class T, std::size_t N>
|
||||
constexpr array<T, N> to_array( T const (&&a)[N] );
|
||||
```
|
||||
[horizontal]
|
||||
Returns: :: an `array<T, N>` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`.
|
||||
|
||||
---
|
||||
|
@ -430,17 +430,62 @@ namespace boost {
|
||||
return arg.elems;
|
||||
}
|
||||
|
||||
template <size_t Idx, typename T, size_t N>
|
||||
BOOST_CXX14_CONSTEXPR T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
||||
return arr[Idx];
|
||||
}
|
||||
template <size_t Idx, typename T, size_t N>
|
||||
BOOST_CXX14_CONSTEXPR T &get(boost::array<T,N> &arr) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(boost::array &) index out of range" );
|
||||
return arr[Idx];
|
||||
}
|
||||
|
||||
template <size_t Idx, typename T, size_t N>
|
||||
BOOST_CONSTEXPR const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT {
|
||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" );
|
||||
return arr[Idx];
|
||||
}
|
||||
template <size_t Idx, typename T, size_t N>
|
||||
BOOST_CONSTEXPR const T &get(const boost::array<T,N> &arr) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG ( Idx < N, "boost::get<>(const boost::array &) index out of range" );
|
||||
return arr[Idx];
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T const (&a)[ N ] )
|
||||
{
|
||||
array<T, N> r = {};
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
r[ i ] = a[ i ];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T (&&a)[ N ] )
|
||||
{
|
||||
array<T, N> r = {};
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
r[ i ] = std::move( a[ i ] );
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
template<class T, std::size_t N>
|
||||
BOOST_CXX14_CONSTEXPR array<T, N> to_array( T const (&&a)[ N ] )
|
||||
{
|
||||
array<T, N> r = {};
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
r[ i ] = a[ i ];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} /* namespace boost */
|
||||
|
||||
|
@ -84,6 +84,7 @@ run array_eq_test.cpp ;
|
||||
run array_lt_test.cpp ;
|
||||
run array_thw_test.cpp ;
|
||||
run array_get_test.cpp ;
|
||||
run to_array_test.cpp ;
|
||||
|
||||
# C++11 constexpr
|
||||
|
||||
@ -103,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 ;
|
||||
|
||||
#
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_ENABLE_ASSERT_HANDLER
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_SYMBOLS
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#define BOOST_ALLOW_DEPRECATED_SYMBOLS
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Copyright 2023 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt)
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
||||
|
109
test/to_array_test.cpp
Normal file
109
test/to_array_test.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
// 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/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
boost::array<int, 3> f1()
|
||||
{
|
||||
boost::array<int, 3> r = {{ 1, 2, 3 }};
|
||||
return r;
|
||||
}
|
||||
|
||||
boost::array<int, 3> const f2()
|
||||
{
|
||||
boost::array<int, 3> r = {{ 1, 2, 3 }};
|
||||
return r;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
int a[] = { 1, 2, 3 };
|
||||
|
||||
boost::array<int, 3> b = boost::to_array( a );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int const a[] = { 1, 2, 3 };
|
||||
|
||||
boost::array<int, 3> b = boost::to_array( a );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::array<int, 3> b = boost::to_array( f1().elems );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::array<int, 3> b = boost::to_array( f2().elems );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
|
||||
#if BOOST_CXX_VERSION >= 201103L
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||
{
|
||||
int a[] = { 1, 2, 3 };
|
||||
|
||||
boost::array<int, 3> b = boost::to_array( std::move( a ) );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
|
||||
{
|
||||
int const a[] = { 1, 2, 3 };
|
||||
|
||||
boost::array<int, 3> b = boost::to_array( std::move( a ) );
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_GCC, < 40900) && !BOOST_WORKAROUND(BOOST_CLANG_VERSION, < 30800)
|
||||
{
|
||||
boost::array<int, 3> b = boost::to_array({ 1, 2, 3 });
|
||||
|
||||
BOOST_TEST_EQ( b[0], 1 );
|
||||
BOOST_TEST_EQ( b[1], 2 );
|
||||
BOOST_TEST_EQ( b[2], 3 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1920)
|
||||
{
|
||||
std::unique_ptr<int> a[] = { {}, {}, {} };
|
||||
|
||||
boost::array<std::unique_ptr<int>, 3> b = boost::to_array( std::move( a ) );
|
||||
|
||||
(void)b;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
32
test/to_array_test_cx.cpp
Normal file
32
test/to_array_test_cx.cpp
Normal 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
|
Reference in New Issue
Block a user