forked from boostorg/core
Compare commits
24 Commits
feature/st
...
develop
Author | SHA1 | Date | |
---|---|---|---|
58f469cd80 | |||
457d6a8ad0 | |||
e3d8de377b | |||
8d25b9ce54 | |||
6e05e5e764 | |||
7cb3e689e0 | |||
11d367377f | |||
f32cb2f696 | |||
21761b3f62 | |||
2e87ab53f7 | |||
8d5ee24c97 | |||
db59ef2a81 | |||
c48b7f269f | |||
4c74671f73 | |||
1e1ccb491e | |||
787b03ea9c | |||
b9a2221b3b | |||
cb603c9c6b | |||
24a8174ef1 | |||
7178a52909 | |||
9a3febf848 | |||
3e147e4ced | |||
1222948a8e | |||
749b6340b5 |
@ -124,7 +124,7 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
linux_pipeline(
|
||||
"Linux 16.04 GCC 4.8 32/64",
|
||||
"cppalliance/droneubuntu1604:1",
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
{ TOOLSET: 'gcc', COMPILER: 'g++-4.8', CXXSTD: '03,11', ADDRMD: '32,64' },
|
||||
"g++-4.8-multilib",
|
||||
),
|
||||
|
||||
|
97
.github/workflows/ci.yml
vendored
97
.github/workflows/ci.yml
vendored
@ -1,5 +1,5 @@
|
||||
# Copyright 2020-2021 Peter Dimov
|
||||
# Copyright 2021-2024 Andrey Semashev
|
||||
# Copyright 2021-2025 Andrey Semashev
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
@ -100,13 +100,13 @@ jobs:
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
address-model: 32,64
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-9-multilib
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
address-model: 32,64
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-24.04
|
||||
install:
|
||||
- g++-10-multilib
|
||||
- toolset: gcc-11
|
||||
@ -125,7 +125,7 @@ jobs:
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
address-model: 32,64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- g++-13-multilib
|
||||
- toolset: gcc-14
|
||||
@ -135,6 +135,13 @@ jobs:
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- g++-14-multilib
|
||||
- toolset: gcc-15
|
||||
cxxstd: "03,11,14,17,20,23,2c"
|
||||
address-model: 32,64
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
install:
|
||||
- g++-15-multilib
|
||||
- name: UBSAN
|
||||
toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20,23"
|
||||
@ -220,13 +227,15 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:20.04
|
||||
install:
|
||||
- clang-10
|
||||
- toolset: clang
|
||||
@ -283,7 +292,7 @@ jobs:
|
||||
compiler: clang++-16
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- clang-16
|
||||
- libc++-16-dev
|
||||
@ -294,7 +303,7 @@ jobs:
|
||||
compiler: clang++-17
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.10
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- clang-17
|
||||
- libc++-17-dev
|
||||
@ -312,6 +321,28 @@ jobs:
|
||||
- libc++abi-18-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-19
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- clang-19
|
||||
- libc++-19-dev
|
||||
- libc++abi-19-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- toolset: clang
|
||||
compiler: clang++-20
|
||||
cxxstd: "03,11,14,17,20,2b,2c"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:25.04
|
||||
install:
|
||||
- clang-20
|
||||
- libc++-20-dev
|
||||
- libc++abi-20-dev
|
||||
cxxflags: -stdlib=libc++
|
||||
linkflags: -stdlib=libc++
|
||||
- name: UBSAN
|
||||
toolset: clang
|
||||
compiler: clang++-15
|
||||
@ -325,6 +356,14 @@ jobs:
|
||||
- libc++-15-dev
|
||||
- libc++abi-15-dev
|
||||
|
||||
- name: ARM
|
||||
toolset: gcc-13
|
||||
cxxstd: "03-gnu,11-gnu,14-gnu,17-gnu,20-gnu,23-gnu"
|
||||
os: ubuntu-24.04-arm
|
||||
container: ubuntu:24.04
|
||||
install:
|
||||
- g++-13
|
||||
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,20,2b"
|
||||
os: macos-13
|
||||
@ -352,6 +391,22 @@ jobs:
|
||||
echo "GHA_CONTAINER=${{matrix.container}}" >> $GITHUB_ENV
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
# Use Azure APT mirrors in containers to avoid HTTP errors due to DDoS filters triggered by lots of CI jobs launching concurrently.
|
||||
# Note that not all Ubuntu versions support "mirror+file:..." URIs in APT sources, so just use Azure mirrors exclusively.
|
||||
# Note also that on recent Ubuntu versions DEB822 format is used for source files.
|
||||
APT_SOURCES=()
|
||||
if [ -d "/etc/apt/sources.list.d" ]
|
||||
then
|
||||
readarray -t APT_SOURCES < <(find "/etc/apt/sources.list.d" -type f -name '*.sources' -print)
|
||||
fi
|
||||
if [ -f "/etc/apt/sources.list" ]
|
||||
then
|
||||
APT_SOURCES+=("/etc/apt/sources.list")
|
||||
fi
|
||||
if [ "${#APT_SOURCES[@]}" -gt 0 ]
|
||||
then
|
||||
sed -i -E -e 's!([^ ]+) (http|https)://(archive|security)\.ubuntu\.com/ubuntu[^ ]*(.*)!\1 http://azure.archive.ubuntu.com/ubuntu/\4!' "${APT_SOURCES[@]}"
|
||||
fi
|
||||
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
|
||||
if [ "$(apt-cache search "^python-is-python3$" | wc -l)" -ne 0 ]
|
||||
then
|
||||
@ -552,14 +607,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: "14"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
@ -571,7 +618,14 @@ jobs:
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
|
||||
# Windows SDK 32-bit ARM libs not installed in this image
|
||||
- name: ARM
|
||||
toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 64
|
||||
os: windows-11-arm
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 45
|
||||
@ -624,7 +678,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
@ -692,7 +745,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
@ -770,7 +822,6 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
@ -852,8 +903,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
@ -914,8 +965,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 10
|
||||
@ -994,8 +1045,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-2025
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
timeout-minutes: 20
|
||||
|
@ -38,7 +38,7 @@ and return type use spans.
|
||||
|
||||
```
|
||||
auto sha1(boost::span<const unsigned char> input,
|
||||
boost::span<unsigned char, SHA_DIGEST_LENGTH> ouput)
|
||||
boost::span<unsigned char, SHA_DIGEST_LENGTH> output)
|
||||
{
|
||||
SHA_CTX context;
|
||||
SHA1_Init(&context);
|
||||
|
@ -28,7 +28,7 @@
|
||||
# pragma intrinsic(_BitScanForward)
|
||||
# pragma intrinsic(_BitScanReverse)
|
||||
|
||||
# if defined(_M_X64)
|
||||
# if defined(_M_X64) || defined(_M_ARM64)
|
||||
# pragma intrinsic(_BitScanForward64)
|
||||
# pragma intrinsic(_BitScanReverse64)
|
||||
# endif
|
||||
@ -230,7 +230,7 @@ inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_X64) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -255,7 +255,7 @@ BOOST_CXX14_CONSTEXPR inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||
#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
|
||||
|
||||
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -455,7 +455,7 @@ inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_X64) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
|
||||
|
||||
BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -480,7 +480,7 @@ BOOST_CXX14_CONSTEXPR inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||
#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64))
|
||||
|
||||
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
@ -703,7 +703,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x )
|
||||
{
|
||||
if( x == 0 )
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
--x;
|
||||
@ -723,7 +723,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x )
|
||||
{
|
||||
if( x == 0 )
|
||||
{
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
--x;
|
||||
|
@ -10,6 +10,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <new>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#if defined( BOOST_CORE_HAS_CXXABI_H )
|
||||
# include <cxxabi.h>
|
||||
// For some archtectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
|
||||
// For some architectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
|
||||
// (https://android.googlesource.com/platform/ndk/+/master/sources/cxx-stl/gabi++/), which does not implement
|
||||
// abi::__cxa_demangle(). We detect this implementation by checking the include guard here.
|
||||
# if defined( __GABIXX_CXXABI_H__ )
|
||||
|
18
include/boost/core/detail/assert.hpp
Normal file
18
include/boost/core/detail/assert.hpp
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
Copyright 2025 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#undef BOOST_CORE_DETAIL_ASSERT
|
||||
|
||||
#if !defined(__clang__) && \
|
||||
!defined(__INTEL_COMPILER) && \
|
||||
defined(__GNUC__) && \
|
||||
(__GNUC__ < 5)
|
||||
#define BOOST_CORE_DETAIL_ASSERT(expr) void(0)
|
||||
#else
|
||||
#include <boost/assert.hpp>
|
||||
#define BOOST_CORE_DETAIL_ASSERT(expr) BOOST_ASSERT(expr)
|
||||
#endif
|
@ -67,7 +67,7 @@ namespace core
|
||||
|
||||
inline void sp_thread_sleep() BOOST_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__) && !defined(__OHOS__)
|
||||
|
||||
int oldst;
|
||||
pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, &oldst );
|
||||
@ -85,7 +85,7 @@ inline void sp_thread_sleep() BOOST_NOEXCEPT
|
||||
|
||||
nanosleep( &rqtp, 0 );
|
||||
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__)
|
||||
#if defined(BOOST_HAS_PTHREADS) && !defined(__ANDROID__) && !defined(__OHOS__)
|
||||
|
||||
pthread_setcancelstate( oldst, &oldst );
|
||||
|
||||
|
@ -378,7 +378,7 @@ public:
|
||||
}
|
||||
|
||||
template<class End> BOOST_CXX14_CONSTEXPR basic_string_view( Ch const* first, End last,
|
||||
typename boost::enable_if<boost::core::detail::is_same<End, Ch const*> >::type* = 0 ) BOOST_NOEXCEPT: p_( first ), n_( static_cast<size_type>( last - first ) )
|
||||
typename boost::enable_if<boost::core::detail::is_same<End, Ch const*>, int >::type = 0 ) BOOST_NOEXCEPT: p_( first ), n_( static_cast<size_type>( last - first ) )
|
||||
{
|
||||
BOOST_ASSERT( last - first >= 0 );
|
||||
}
|
||||
@ -396,7 +396,7 @@ public:
|
||||
#endif
|
||||
|
||||
template<class Ch2> basic_string_view( boost::basic_string_view<Ch2, std::char_traits<Ch2> > const& str,
|
||||
typename boost::enable_if<boost::core::detail::is_same<Ch, Ch2> >::type* = 0 ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
typename boost::enable_if<boost::core::detail::is_same<Ch, Ch2>, int >::type = 0 ) BOOST_NOEXCEPT: p_( str.data() ), n_( str.size() )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace boost
|
||||
/**
|
||||
* Casts a scoped enum to its underlying type.
|
||||
*
|
||||
* This function is useful when working with scoped enum classes, which doens't implicitly convert to the underlying type.
|
||||
* This function is useful when working with scoped enum classes, which doesn't implicitly convert to the underlying type.
|
||||
* @param v A scoped enum.
|
||||
* @returns The underlying type.
|
||||
* @throws No-throws.
|
||||
|
@ -8,6 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#ifndef BOOST_CORE_SPAN_HPP
|
||||
#define BOOST_CORE_SPAN_HPP
|
||||
|
||||
#include <boost/core/detail/assert.hpp>
|
||||
#include <boost/core/data.hpp>
|
||||
#include <array>
|
||||
#include <iterator>
|
||||
@ -274,17 +275,21 @@ public:
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> first(size_type c) const {
|
||||
return span<T, dynamic_extent>(s_.p, c);
|
||||
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
|
||||
span<T, dynamic_extent>(s_.p, c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> last(size_type c) const {
|
||||
return span<T, dynamic_extent>(s_.p + (s_.n - c), c);
|
||||
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
|
||||
span<T, dynamic_extent>(s_.p + (s_.n - c), c);
|
||||
}
|
||||
|
||||
constexpr span<T, dynamic_extent> subspan(size_type o,
|
||||
size_type c = dynamic_extent) const {
|
||||
return span<T, dynamic_extent>(s_.p + o,
|
||||
c == dynamic_extent ? s_.n - o : c);
|
||||
return BOOST_CORE_DETAIL_ASSERT(o <= size() &&
|
||||
(c == dynamic_extent || c + o <= size())),
|
||||
span<T, dynamic_extent>(s_.p + o,
|
||||
c == dynamic_extent ? s_.n - o : c);
|
||||
}
|
||||
|
||||
constexpr size_type size() const noexcept {
|
||||
@ -300,15 +305,15 @@ public:
|
||||
}
|
||||
|
||||
constexpr reference operator[](size_type i) const {
|
||||
return s_.p[i];
|
||||
return BOOST_CORE_DETAIL_ASSERT(i < size()), s_.p[i];
|
||||
}
|
||||
|
||||
constexpr reference front() const {
|
||||
return *s_.p;
|
||||
return BOOST_CORE_DETAIL_ASSERT(!empty()), *s_.p;
|
||||
}
|
||||
|
||||
constexpr reference back() const {
|
||||
return s_.p[s_.n - 1];
|
||||
return BOOST_CORE_DETAIL_ASSERT(!empty()), s_.p[s_.n - 1];
|
||||
}
|
||||
|
||||
constexpr pointer data() const noexcept {
|
||||
|
@ -409,6 +409,7 @@ run span_test.cpp ;
|
||||
run span_types_test.cpp ;
|
||||
run span_constructible_test.cpp ;
|
||||
run span_deduction_guide_test.cpp ;
|
||||
run span_constexpr_test.cpp ;
|
||||
run as_bytes_test.cpp ;
|
||||
run as_writable_bytes_test.cpp ;
|
||||
compile span_boost_begin_test.cpp ;
|
||||
|
@ -19,14 +19,15 @@ template<class T> void test_bit_ceil( T x )
|
||||
|
||||
T y = boost::core::bit_ceil( x );
|
||||
|
||||
BOOST_TEST( boost::core::has_single_bit( y ) );
|
||||
BOOST_TEST_GE( +y, +x );
|
||||
|
||||
if( x == 0 )
|
||||
{
|
||||
BOOST_TEST_EQ( y, 0 );
|
||||
BOOST_TEST_EQ( y, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_TEST( boost::core::has_single_bit( y ) );
|
||||
BOOST_TEST_GE( +y, +x );
|
||||
BOOST_TEST_LT( y >> 1, +x );
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ using std::distance;
|
||||
|
||||
*/
|
||||
|
||||
// struct C {} doesn't wotk with libc++.
|
||||
// struct C {} doesn't work with libc++.
|
||||
typedef std::forward_iterator_tag C;
|
||||
|
||||
struct T
|
||||
|
72
test/span_constexpr_test.cpp
Normal file
72
test/span_constexpr_test.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright 2025 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_CONSTEXPR)
|
||||
#include <boost/core/span.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
constexpr const int array[4]{ 5, 10, 15, 20 };
|
||||
|
||||
void test_first()
|
||||
{
|
||||
constexpr boost::span<const int> s =
|
||||
boost::span<const int>(array, 4).first(2);
|
||||
BOOST_TEST_EQ(s.data(), &array[0]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_last()
|
||||
{
|
||||
constexpr boost::span<const int> s =
|
||||
boost::span<const int>(array, 4).last(2);
|
||||
BOOST_TEST_EQ(s.data(), &array[2]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_subspan()
|
||||
{
|
||||
constexpr boost::span<const int> s =
|
||||
boost::span<const int>(array, 4).subspan(1, 2);
|
||||
BOOST_TEST_EQ(s.data(), &array[1]);
|
||||
BOOST_TEST_EQ(s.size(), 2);
|
||||
}
|
||||
|
||||
void test_index()
|
||||
{
|
||||
constexpr const int i = boost::span<const int>(array, 4)[1];
|
||||
BOOST_TEST_EQ(i, 10);
|
||||
}
|
||||
|
||||
void test_front()
|
||||
{
|
||||
constexpr const int i = boost::span<const int>(array, 4).front();
|
||||
BOOST_TEST_EQ(i, 5);
|
||||
}
|
||||
|
||||
void test_back()
|
||||
{
|
||||
constexpr const int i = boost::span<const int>(array, 4).back();
|
||||
BOOST_TEST_EQ(i, 20);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_first();
|
||||
test_last();
|
||||
test_subspan();
|
||||
test_index();
|
||||
test_front();
|
||||
test_back();
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -9,7 +9,7 @@
|
||||
// objects to be swapped would themselves be from the boost namespace.
|
||||
// If so, boost::core::invoke_swap itself might be found by argument dependent lookup.
|
||||
// The implementation of boost::core::invoke_swap resolves this issue by giving
|
||||
// boost::core::invoke_swap two template argumetns, thereby making it less specialized
|
||||
// boost::core::invoke_swap two template arguments, thereby making it less specialized
|
||||
// than std::swap.
|
||||
|
||||
#include <boost/core/invoke_swap.hpp>
|
||||
|
@ -12,7 +12,7 @@
|
||||
//Put test class in the global namespace
|
||||
#include "./swap_test_class.hpp"
|
||||
|
||||
//Provide swap function in gloabl namespace
|
||||
//Provide swap function in global namespace
|
||||
void swap(swap_test_class& left, swap_test_class& right)
|
||||
{
|
||||
left.swap(right);
|
||||
|
Reference in New Issue
Block a user