forked from boostorg/array
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 43326390d9 | |||
| c95d855018 | |||
| 0a72026887 | |||
| d2c295b85f | |||
| 324827cfc0 | |||
| 9253e8f1af |
@@ -14,3 +14,5 @@ http://www.boost.org/LICENSE_1_0.txt
|
|||||||
|
|
||||||
* Converted documentation to AsciiDoc (Christian Mazakas).
|
* Converted documentation to AsciiDoc (Christian Mazakas).
|
||||||
* Added `noexcept` and `constexpr` as appropriate.
|
* Added `noexcept` and `constexpr` as appropriate.
|
||||||
|
* Marked obsolete functions as deprecated.
|
||||||
|
* Removed obsolete compiler workarounds.
|
||||||
|
|||||||
+3
-12
@@ -303,18 +303,9 @@ namespace boost {
|
|||||||
BOOST_CXX14_CONSTEXPR void fill (const T& ) {}
|
BOOST_CXX14_CONSTEXPR void fill (const T& ) {}
|
||||||
|
|
||||||
// check range (may be private because it is static)
|
// check range (may be private because it is static)
|
||||||
static reference failed_rangecheck () {
|
static reference failed_rangecheck ()
|
||||||
std::out_of_range e("attempt to access element of an empty array");
|
{
|
||||||
boost::throw_exception(e);
|
boost::throw_exception( std::out_of_range( "attempt to access element of an empty array" ) );
|
||||||
#if defined(BOOST_NO_EXCEPTIONS) || (!defined(BOOST_MSVC) && !defined(__PATHSCALE__))
|
|
||||||
//
|
|
||||||
// We need to return something here to keep
|
|
||||||
// some compilers happy: however we will never
|
|
||||||
// actually get here....
|
|
||||||
//
|
|
||||||
static T placeholder;
|
|
||||||
return placeholder;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ compile array_get_test_cx.cpp ;
|
|||||||
|
|
||||||
# C++14 constexpr
|
# C++14 constexpr
|
||||||
|
|
||||||
|
compile array_assign_test_cx.cpp ;
|
||||||
|
compile array_access_test_cx2.cpp ;
|
||||||
|
compile array_fill_test_cx.cpp ;
|
||||||
compile array_eq_test_cx.cpp ;
|
compile array_eq_test_cx.cpp ;
|
||||||
compile array_lt_test_cx.cpp ;
|
compile array_lt_test_cx.cpp ;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// 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__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> constexpr boost::array<T, N> modified( boost::array<T, N> a1 )
|
||||||
|
{
|
||||||
|
a1.front() = 1;
|
||||||
|
a1[ 1 ] = 2;
|
||||||
|
a1.at( 2 ) = 3;
|
||||||
|
a1.back() = 4;
|
||||||
|
|
||||||
|
return a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {};
|
||||||
|
constexpr boost::array<T, 4> a2 = modified( a1 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a2[0] == 1 );
|
||||||
|
STATIC_ASSERT( a2[1] == 2 );
|
||||||
|
STATIC_ASSERT( a2[2] == 3 );
|
||||||
|
STATIC_ASSERT( a2[3] == 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -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 <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__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> constexpr boost::array<T, N> assigned( boost::array<T, N> const& a1 )
|
||||||
|
{
|
||||||
|
boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
a2 = a1;
|
||||||
|
|
||||||
|
return a2;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = assigned( a1 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1[0] == a2[0] );
|
||||||
|
STATIC_ASSERT( a1[1] == a2[1] );
|
||||||
|
STATIC_ASSERT( a1[2] == a2[2] );
|
||||||
|
STATIC_ASSERT( a1[3] == a2[3] );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a1 = {};
|
||||||
|
constexpr boost::array<T, 0> a2 = assigned( a1 );
|
||||||
|
|
||||||
|
(void)a1;
|
||||||
|
(void)a2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int>();
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
// 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__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> constexpr boost::array<T, N> filled( T const& v )
|
||||||
|
{
|
||||||
|
boost::array<T, N> r = {};
|
||||||
|
|
||||||
|
r.fill( v );
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test1()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = filled<T, 4>( 7 );
|
||||||
|
|
||||||
|
STATIC_ASSERT( a1[0] == 7 );
|
||||||
|
STATIC_ASSERT( a1[1] == 7 );
|
||||||
|
STATIC_ASSERT( a1[2] == 7 );
|
||||||
|
STATIC_ASSERT( a1[3] == 7 );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 0> a1 = filled<T, 0>( 7 );
|
||||||
|
|
||||||
|
(void)a1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int>();
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -58,7 +58,7 @@ int main()
|
|||||||
test2<int, 1>();
|
test2<int, 1>();
|
||||||
test2<int, 7>();
|
test2<int, 7>();
|
||||||
|
|
||||||
// test2<int const, 0>();
|
test2<int const, 0>();
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) || BOOST_WORKAROUND(BOOST_GCC, < 50000)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user