mirror of
https://github.com/boostorg/array.git
synced 2026-06-16 17:12:37 +02:00
Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8991751e3b | |||
| b2f6f0ca65 | |||
| 703ad46b81 | |||
| 7482efd0a1 | |||
| 61bbcbf341 | |||
| 59e9940d5b | |||
| 771750f7e1 | |||
| 75db85d1e9 | |||
| 49e2a46c3a | |||
| 07a14f33ef | |||
| 047ba01807 | |||
| 45de3be80c | |||
| 68db6ebd2d | |||
| 329e59454f | |||
| 9a4010b88b | |||
| 527ff0a80d | |||
| f017dac435 | |||
| 567ba40840 | |||
| 29700ff270 | |||
| 78fb6a71dd | |||
| 40e2a2d4d8 | |||
| fc10453994 | |||
| 28d8d30b57 | |||
| fe1e99eb31 | |||
| 1469f4b28e | |||
| d535c37a57 | |||
| 36bba5af2d |
@@ -16,7 +16,6 @@ target_link_libraries(boost_array
|
|||||||
INTERFACE
|
INTERFACE
|
||||||
Boost::assert
|
Boost::assert
|
||||||
Boost::config
|
Boost::config
|
||||||
Boost::core
|
|
||||||
Boost::static_assert
|
Boost::static_assert
|
||||||
Boost::throw_exception
|
Boost::throw_exception
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Copyright 2023-2024 René Ferdinand Rivera Morell
|
||||||
|
# Copyright 2024 Peter Dimov
|
||||||
|
# Distributed under the Boost Software License, Version 1.0.
|
||||||
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
require-b2 5.2 ;
|
||||||
|
|
||||||
|
constant boost_dependencies :
|
||||||
|
/boost/assert//boost_assert
|
||||||
|
/boost/config//boost_config
|
||||||
|
/boost/static_assert//boost_static_assert
|
||||||
|
/boost/throw_exception//boost_throw_exception
|
||||||
|
;
|
||||||
|
|
||||||
|
project /boost/array ;
|
||||||
|
|
||||||
|
explicit
|
||||||
|
[ alias boost_array : : : : <include>include <library>$(boost_dependencies) ]
|
||||||
|
[ alias all : boost_array test ]
|
||||||
|
;
|
||||||
|
|
||||||
|
call-if : boost-library array
|
||||||
|
;
|
||||||
|
|
||||||
@@ -18,3 +18,6 @@ http://www.boost.org/LICENSE_1_0.txt
|
|||||||
* Removed obsolete compiler workarounds.
|
* Removed obsolete compiler workarounds.
|
||||||
* Changed `array<T, 0>::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`.
|
* Changed `array<T, 0>::begin()`, `cbegin()`, `end()`, `cend()` to return `nullptr`, enabling `constexpr`.
|
||||||
This matches the behavior of `std::array`.
|
This matches the behavior of `std::array`.
|
||||||
|
* Removed local `hash_value` overload; `boost::hash` supports array-like types natively.
|
||||||
|
* `array<T, 0>` can now be initialized with `= {{}}`.
|
||||||
|
* Added `operator\<\=>`.
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ namespace boost {
|
|||||||
template<typename T, std::size_t N>
|
template<typename T, std::size_t N>
|
||||||
constexpr bool operator>=(const array<T, N>&, const array<T, N>&);
|
constexpr bool operator>=(const array<T, N>&, const array<T, N>&);
|
||||||
|
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr auto operator<=>(const array<T, N>&, const array<T, N>&);
|
||||||
|
|
||||||
template<std::size_t Idx, typename T, std::size_t N>
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
constexpr T& get(array<T, N>&) noexcept;
|
constexpr T& get(array<T, N>&) noexcept;
|
||||||
template<std::size_t Idx, typename T, std::size_t N>
|
template<std::size_t Idx, typename T, std::size_t N>
|
||||||
@@ -136,7 +139,7 @@ public:
|
|||||||
template<typename U> array& operator=(const array<U, N>& other);
|
template<typename U> array& operator=(const array<U, N>& other);
|
||||||
```
|
```
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Effects: :: `std::copy(rhs.begin(), rhs.end(), begin())`.
|
Effects: :: For each `i` in `[0..N)`, performs `elems[i] = other.elems[i];`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -233,7 +236,7 @@ constexpr const_reference operator[](size_type i) const;
|
|||||||
[horizontal]
|
[horizontal]
|
||||||
Requires: :: `i < N`.
|
Requires: :: `i < N`.
|
||||||
Returns: :: `elems[i]`.
|
Returns: :: `elems[i]`.
|
||||||
Throws: :: nothing.
|
Throws: :: Nothing.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -254,7 +257,7 @@ constexpr const_reference front() const;
|
|||||||
[horizontal]
|
[horizontal]
|
||||||
Requires: :: `N > 0`.
|
Requires: :: `N > 0`.
|
||||||
Returns: :: `elems[0]`.
|
Returns: :: `elems[0]`.
|
||||||
Throws: :: nothing.
|
Throws: :: Nothing.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -265,7 +268,7 @@ constexpr const_reference back() const;
|
|||||||
[horizontal]
|
[horizontal]
|
||||||
Requires: :: `N > 0`.
|
Requires: :: `N > 0`.
|
||||||
Returns: :: `elems[N-1]`.
|
Returns: :: `elems[N-1]`.
|
||||||
Throws: :: nothing.
|
Throws: :: Nothing.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -302,7 +305,7 @@ Complexity: :: linear in `N`.
|
|||||||
void fill(const T& value);
|
void fill(const T& value);
|
||||||
```
|
```
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Effects: :: for each `i` in `[0..N)`, performs `elems[i] = value;`.
|
Effects: :: For each `i` in `[0..N)`, performs `elems[i] = value;`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -382,6 +385,17 @@ Returns: :: `!(x < y)`.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
```
|
||||||
|
template<typename T, std::size_t N>
|
||||||
|
constexpr auto operator<=>(const array<T, N>& x, const array<T, N>& y)
|
||||||
|
-> decltype(x[0] <=> y[0]);
|
||||||
|
```
|
||||||
|
[horizontal]
|
||||||
|
Effects: :: For each `i` in `[0..N)`, if `(x[i] \<\=> y[i]) != 0`, returns `x[i] \<\=> y[i]`. Otherwise, returns `std::strong_ordering::equal`, converted to the return type.
|
||||||
|
Remarks: :: When `N` is 0, the return type is `std::strong_ordering` and the return value is `std::strong_ordering::equal`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Specializations
|
### Specializations
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
+32
-5
@@ -37,9 +37,10 @@
|
|||||||
|
|
||||||
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4510) // boost::array<T,N>' : default constructor could not be generated
|
# pragma warning(disable: 4510) // boost::array<T,N>' : default constructor could not be generated
|
||||||
# pragma warning(disable:4512) // boost::array<T,N>' : assignment operator could not be generated
|
# pragma warning(disable: 4512) // boost::array<T,N>' : assignment operator could not be generated
|
||||||
# pragma warning(disable:4610) // class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
# pragma warning(disable: 4610) // class 'boost::array<T,N>' can never be instantiated - user defined constructor required
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@@ -195,6 +196,8 @@ namespace boost {
|
|||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
class array< T, 0 > {
|
class array< T, 0 > {
|
||||||
|
public:
|
||||||
|
struct {} elems; // enables initialization with = {{}}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// type definitions
|
// type definitions
|
||||||
@@ -324,7 +327,7 @@ namespace boost {
|
|||||||
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOST_CXX14_CONSTEXPR bool operator== (const array<T, 0>& x, const array<T, 0>& y)
|
BOOST_CXX14_CONSTEXPR bool operator== (const array<T, 0>& /*x*/, const array<T, 0>& /*y*/)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -351,7 +354,7 @@ namespace boost {
|
|||||||
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
#if BOOST_WORKAROUND(BOOST_GCC, < 90000)
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
BOOST_CXX14_CONSTEXPR bool operator< (const array<T, 0>& x, const array<T, 0>& y)
|
BOOST_CXX14_CONSTEXPR bool operator< (const array<T, 0>& /*x*/, const array<T, 0>& /*y*/)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -379,6 +382,30 @@ namespace boost {
|
|||||||
x.swap(y);
|
x.swap(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201907L
|
||||||
|
|
||||||
|
template<class T, std::size_t N>
|
||||||
|
constexpr auto operator<=> (const array<T,N>& x, const array<T,N>& y)
|
||||||
|
-> decltype( x.elems[ 0 ] <=> y.elems[ 0 ] )
|
||||||
|
{
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
auto r = x.elems[ i ] <=> y.elems[ i ];
|
||||||
|
if( r != 0 ) return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0 <=> 0; // std::strong_ordering::equal
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
constexpr auto operator<=> (const array<T,0>& /*x*/, const array<T,0>& /*y*/)
|
||||||
|
-> decltype( 0 <=> 0 )
|
||||||
|
{
|
||||||
|
return 0 <=> 0; // std::strong_ordering::equal
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// undocumented and obsolete
|
// undocumented and obsolete
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
BOOST_DEPRECATED( "please use `elems` instead" )
|
BOOST_DEPRECATED( "please use `elems` instead" )
|
||||||
|
|||||||
+42
-3
@@ -7,6 +7,41 @@ import testing ;
|
|||||||
import-search /boost/config/checks ;
|
import-search /boost/config/checks ;
|
||||||
import config : requires ;
|
import config : requires ;
|
||||||
|
|
||||||
|
project
|
||||||
|
: requirements
|
||||||
|
|
||||||
|
<library>/boost/array//boost_array
|
||||||
|
<library>/boost/core//boost_core
|
||||||
|
|
||||||
|
<warnings>extra
|
||||||
|
|
||||||
|
<toolset>msvc:<warnings-as-errors>on
|
||||||
|
<toolset>clang:<warnings-as-errors>on
|
||||||
|
<toolset>gcc:<warnings-as-errors>on
|
||||||
|
|
||||||
|
<toolset>gcc-4.6:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>gcc-4.7:<cxxflags>-Wno-missing-braces
|
||||||
|
|
||||||
|
<toolset>gcc-4.6:<cxxflags>-Wno-missing-field-initializers
|
||||||
|
<toolset>gcc-4.7:<cxxflags>-Wno-missing-field-initializers
|
||||||
|
<toolset>gcc-4.8:<cxxflags>-Wno-missing-field-initializers
|
||||||
|
<toolset>gcc-4.9:<cxxflags>-Wno-missing-field-initializers
|
||||||
|
|
||||||
|
<toolset>gcc-4.6:<cxxflags>-Wno-type-limits
|
||||||
|
<toolset>gcc-4.7:<cxxflags>-Wno-type-limits
|
||||||
|
<toolset>gcc-10:<cxxflags>-Wno-type-limits
|
||||||
|
|
||||||
|
<toolset>clang:<cxxflags>-Wno-unnamed-type-template-args
|
||||||
|
|
||||||
|
<toolset>clang-3.5:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-3.6:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-3.7:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-3.8:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-3.9:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-4:<cxxflags>-Wno-missing-braces
|
||||||
|
<toolset>clang-5:<cxxflags>-Wno-missing-braces
|
||||||
|
;
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
run array0.cpp ;
|
run array0.cpp ;
|
||||||
@@ -20,11 +55,13 @@ run array7.cpp ;
|
|||||||
|
|
||||||
compile array_constexpr.cpp ;
|
compile array_constexpr.cpp ;
|
||||||
|
|
||||||
compile-fail array_getfail1.cpp ;
|
compile-fail array_getfail1.cpp
|
||||||
compile-fail array_getfail2.cpp ;
|
: <warnings>off ;
|
||||||
|
compile-fail array_getfail2.cpp
|
||||||
|
: <warnings>off ;
|
||||||
|
|
||||||
run array_hash.cpp
|
run array_hash.cpp
|
||||||
: : : [ requires cxx11_noexcept ] ;
|
: : : <library>/boost/container_hash//boost_container_hash [ requires cxx11_noexcept ] ;
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -45,6 +82,7 @@ run array_swap_test.cpp ;
|
|||||||
run array_swap_test2.cpp ;
|
run array_swap_test2.cpp ;
|
||||||
run array_eq_test.cpp ;
|
run array_eq_test.cpp ;
|
||||||
run array_lt_test.cpp ;
|
run array_lt_test.cpp ;
|
||||||
|
run array_thw_test.cpp ;
|
||||||
run array_get_test.cpp ;
|
run array_get_test.cpp ;
|
||||||
|
|
||||||
# C++11 constexpr
|
# C++11 constexpr
|
||||||
@@ -64,6 +102,7 @@ compile array_access_test_cx2.cpp ;
|
|||||||
compile array_fill_test_cx.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 ;
|
||||||
|
compile array_thw_test_cx.cpp ;
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // assign
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -5,12 +5,20 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // get_c_array
|
||||||
|
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/array.hpp>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <boost/core/lightweight_test_trait.hpp>
|
#if defined(BOOST_GCC) && BOOST_GCC / 10000 == 13
|
||||||
|
// false -Warray-bounds positive when using -fsanitize=undefined
|
||||||
|
// restricted to GCC 13 because that's what is tested on Drone
|
||||||
|
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template< class T >
|
template< class T >
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
* http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define BOOST_ALLOW_DEPRECATED_SYMBOLS // std::get
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
|||||||
@@ -2,12 +2,17 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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
|
||||||
|
|
||||||
|
// assign is a deprecated nonstandard equivalent of fill
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
// assign is a nonstandard equivalent of fill
|
#if defined(_MSC_VER)
|
||||||
// it probably needs to be deprecated and removed
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0.
|
// 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
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
// c_array and get_c_array are nonstandard extensions
|
// c_array and get_c_array are deprecated nonstandard extensions
|
||||||
// probably need to be deprecated and removed
|
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,11 +44,11 @@ template<class T> void test4()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// test1<int, 0>();
|
test1<int, 0>();
|
||||||
test1<int, 1>();
|
test1<int, 1>();
|
||||||
test1<int, 7>();
|
test1<int, 7>();
|
||||||
|
|
||||||
// test1<int const, 0>();
|
test1<int const, 0>();
|
||||||
test1<int const, 1>();
|
test1<int const, 1>();
|
||||||
test1<int const, 7>();
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
boost::array<T, N> a = {};
|
boost::array<T, N> a = {};
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test1()
|
template<class T, std::size_t N> void test1()
|
||||||
{
|
{
|
||||||
boost::array<T, N> a = {{}};
|
boost::array<T, N> a = {{}};
|
||||||
@@ -46,11 +50,11 @@ template<class T> void test4()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// test1<int, 0>();
|
test1<int, 0>();
|
||||||
test1<int, 1>();
|
test1<int, 1>();
|
||||||
test1<int, 7>();
|
test1<int, 7>();
|
||||||
|
|
||||||
// test1<int const, 0>();
|
test1<int const, 0>();
|
||||||
test1<int const, 1>();
|
test1<int const, 1>();
|
||||||
test1<int const, 7>();
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ template<class T> void test4()
|
|||||||
|
|
||||||
template<class T> void test5()
|
template<class T> void test5()
|
||||||
{
|
{
|
||||||
// constexpr boost::array<T, 0> a = {{}};
|
constexpr boost::array<T, 0> a = {{}};
|
||||||
|
(void)a;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void test6()
|
template<class T> void test6()
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ template<class T> void test2()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// test<int, 0>();
|
test<int, 0>();
|
||||||
test<int, 1>();
|
test<int, 1>();
|
||||||
test<int, 7>();
|
test<int, 7>();
|
||||||
|
|
||||||
// test<int const, 0>();
|
test<int const, 0>();
|
||||||
test<int const, 1>();
|
test<int const, 1>();
|
||||||
test<int const, 7>();
|
test<int const, 7>();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,11 +76,11 @@ template<class T, std::size_t N> void test()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// test<int, 0>();
|
test<int, 0>();
|
||||||
test<int, 1>();
|
test<int, 1>();
|
||||||
test<int, 7>();
|
test<int, 7>();
|
||||||
|
|
||||||
// test<int const, 0>();
|
test<int const, 0>();
|
||||||
test<int const, 1>();
|
test<int const, 1>();
|
||||||
test<int const, 7>();
|
test<int const, 7>();
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ template<class T, std::size_t N> void test1()
|
|||||||
BOOST_TEST_EQ( a.size(), N );
|
BOOST_TEST_EQ( a.size(), N );
|
||||||
BOOST_TEST_EQ( a.empty(), N == 0 );
|
BOOST_TEST_EQ( a.empty(), N == 0 );
|
||||||
BOOST_TEST_EQ( a.max_size(), N );
|
BOOST_TEST_EQ( a.max_size(), N );
|
||||||
|
|
||||||
|
(void)a; // msvc-12.0
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -23,6 +25,8 @@ template<class T, std::size_t N> void test1()
|
|||||||
BOOST_TEST_EQ( a.size(), N );
|
BOOST_TEST_EQ( a.size(), N );
|
||||||
BOOST_TEST_EQ( a.empty(), N == 0 );
|
BOOST_TEST_EQ( a.empty(), N == 0 );
|
||||||
BOOST_TEST_EQ( a.max_size(), N );
|
BOOST_TEST_EQ( a.max_size(), N );
|
||||||
|
|
||||||
|
(void)a; // msvc-12.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,11 +53,11 @@ template<class T, std::size_t N> void test3()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// test1<int, 0>();
|
test1<int, 0>();
|
||||||
test1<int, 1>();
|
test1<int, 1>();
|
||||||
test1<int, 7>();
|
test1<int, 7>();
|
||||||
|
|
||||||
// test1<int const, 0>();
|
test1<int const, 0>();
|
||||||
test1<int const, 1>();
|
test1<int const, 1>();
|
||||||
test1<int const, 7>();
|
test1<int const, 7>();
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
boost::array<T, N> a1 = {};
|
boost::array<T, N> a1 = {};
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
#include <boost/core/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
# pragma warning(disable: 4702) // unreachable code
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class T, std::size_t N> void test()
|
template<class T, std::size_t N> void test()
|
||||||
{
|
{
|
||||||
boost::array<T, N> a1 = {};
|
boost::array<T, N> a1 = {};
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
// 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/pragma_message.hpp>
|
||||||
|
#include <cstddef>
|
||||||
|
|
||||||
|
#if !defined(__cpp_impl_three_way_comparison)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#elif !( __cpp_impl_three_way_comparison >= 201907L )
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test()
|
||||||
|
{
|
||||||
|
constexpr auto eq = 0 <=> 0;
|
||||||
|
constexpr auto lt = 0 <=> 1;
|
||||||
|
constexpr auto gt = 1 <=> 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a1 = {};
|
||||||
|
boost::array<T, N> const a2 = {};
|
||||||
|
|
||||||
|
BOOST_TEST( ( a1 <=> a2 ) == eq );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1;
|
||||||
|
boost::array<T, N> a2;
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( ( a1 <=> a2 ) == eq );
|
||||||
|
}
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < N; ++i )
|
||||||
|
{
|
||||||
|
boost::array<T, N> a1;
|
||||||
|
boost::array<T, N> a2;
|
||||||
|
|
||||||
|
a1.fill( 1 );
|
||||||
|
a2.fill( 1 );
|
||||||
|
|
||||||
|
a1[ i ] = 0;
|
||||||
|
|
||||||
|
BOOST_TEST( ( a1 <=> a2 ) == lt );
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a3 = a1;
|
||||||
|
boost::array<T, N> const a4 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( ( a3 <=> a4 ) == lt );
|
||||||
|
}
|
||||||
|
|
||||||
|
a1[ i ] = 2;
|
||||||
|
|
||||||
|
BOOST_TEST( ( a1 <=> a2 ) == gt );
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::array<T, N> const a3 = a1;
|
||||||
|
boost::array<T, N> const a4 = a2;
|
||||||
|
|
||||||
|
BOOST_TEST( ( a3 <=> a4 ) == gt );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test<int, 0>();
|
||||||
|
test<int, 1>();
|
||||||
|
test<int, 7>();
|
||||||
|
|
||||||
|
test<float, 0>();
|
||||||
|
test<float, 1>();
|
||||||
|
test<float, 7>();
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// 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(__cpp_impl_three_way_comparison)
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is not defined" )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#elif !( __cpp_impl_three_way_comparison >= 201907L )
|
||||||
|
|
||||||
|
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_impl_three_way_comparison is defined to " BOOST_STRINGIZE(__cpp_impl_three_way_comparison) )
|
||||||
|
int main() {}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
|
||||||
|
|
||||||
|
template<class T, std::size_t N> void test1()
|
||||||
|
{
|
||||||
|
constexpr auto eq = 0 <=> 0;
|
||||||
|
|
||||||
|
constexpr boost::array<T, N> a1 = {};
|
||||||
|
constexpr boost::array<T, N> a2 = {};
|
||||||
|
|
||||||
|
STATIC_ASSERT( ( a1 <=> a2 ) == eq );
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void test2()
|
||||||
|
{
|
||||||
|
constexpr auto eq = 0 <=> 0;
|
||||||
|
constexpr auto lt = 0 <=> 1;
|
||||||
|
constexpr auto gt = 1 <=> 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 4 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( ( a1 <=> a2 ) == eq );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 5 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( ( a1 <=> a2 ) == lt );
|
||||||
|
}
|
||||||
|
{
|
||||||
|
constexpr boost::array<T, 4> a1 = {{ 1, 2, 3, 4 }};
|
||||||
|
constexpr boost::array<T, 4> a2 = {{ 1, 2, 3, 2 }};
|
||||||
|
|
||||||
|
STATIC_ASSERT( ( a1 <=> a2 ) == gt );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
test1<int, 0>();
|
||||||
|
test1<int, 1>();
|
||||||
|
test1<int, 7>();
|
||||||
|
|
||||||
|
test2<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user