Compare commits

..

3 Commits

Author SHA1 Message Date
Peter Dimov d92a7b0498 Disable span_constexpr_test under GCC 4.x 2025-02-23 19:19:23 +02:00
Peter Dimov 5f6bb283fb Disable constexpr under GCC 4.x when there's BOOST_ASSERT 2025-02-23 18:55:04 +02:00
Peter Dimov 6b1d7a91e6 Use BOOST_ASSERT instead of BOOST_CORE_DETAIL_ASSERT 2025-02-23 18:55:04 +02:00
38 changed files with 137 additions and 539 deletions
+9 -22
View File
@@ -34,6 +34,7 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
'set -e',
'uname -a',
'echo $DRONE_STAGE_MACHINE',
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
] +
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
@@ -234,13 +235,6 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
"g++-14-multilib",
),
linux_pipeline(
"Linux 25.04 GCC 15 32/64",
"cppalliance/droneubuntu2504:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-15', CXXSTD: '03,11,14,17,20,23,2c', ADDRMD: '32,64' },
"g++-15-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
@@ -375,33 +369,26 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 Clang 18",
"Linux 24.04 Clang 18 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 19 UBSAN",
"Linux 24.04 Clang 18 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
"clang-19",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan,
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 19 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' } + asan,
"Linux 24.10 Clang 19",
"cppalliance/droneubuntu2410:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' },
"clang-19",
),
linux_pipeline(
"Linux 25.04 Clang 20",
"cppalliance/droneubuntu2504:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '03,11,14,17,20,23,2c' },
"clang-20",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
+22 -62
View File
@@ -1,5 +1,5 @@
# Copyright 2020-2021 Peter Dimov
# Copyright 2021-2025 Andrey Semashev
# Copyright 2021-2024 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-24.04
os: ubuntu-20.04
install:
- g++-9-multilib
- toolset: gcc-10
cxxstd: "03,11,14,17,20"
address-model: 32,64
os: ubuntu-24.04
os: ubuntu-20.04
install:
- g++-10-multilib
- toolset: gcc-11
@@ -135,13 +135,6 @@ 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"
@@ -227,15 +220,13 @@ jobs:
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-latest
container: ubuntu:20.04
os: ubuntu-20.04
install:
- clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,20"
os: ubuntu-latest
container: ubuntu:20.04
os: ubuntu-20.04
install:
- clang-10
- toolset: clang
@@ -325,24 +316,13 @@ jobs:
compiler: clang++-19
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.04
container: ubuntu:24.10
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
@@ -356,14 +336,6 @@ 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
@@ -391,22 +363,6 @@ 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
@@ -607,6 +563,14 @@ 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
@@ -618,17 +582,10 @@ jobs:
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
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
os: windows-2019
runs-on: ${{matrix.os}}
timeout-minutes: 60
timeout-minutes: 45
steps:
- name: Setup Boost
@@ -678,6 +635,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
@@ -745,6 +703,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
@@ -822,6 +781,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
@@ -903,8 +863,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
timeout-minutes: 10
@@ -965,8 +925,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
timeout-minutes: 10
@@ -1045,8 +1005,8 @@ jobs:
fail-fast: false
matrix:
include:
- os: windows-2019
- os: windows-2022
- os: windows-2025
runs-on: ${{matrix.os}}
timeout-minutes: 20
+2 -1
View File
@@ -16,10 +16,11 @@ target_link_libraries(boost_core
INTERFACE
Boost::assert
Boost::config
Boost::static_assert
Boost::throw_exception
)
if(NOT CMAKE_VERSION VERSION_LESS 3.19 AND CMAKE_GENERATOR MATCHES "Visual Studio")
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
file(GLOB_RECURSE boost_core_IDEFILES CONFIGURE_DEPENDS include/*.hpp)
source_group(TREE ${PROJECT_SOURCE_DIR}/include FILES ${boost_core_IDEFILES} PREFIX "Header Files")
+5 -5
View File
@@ -6,14 +6,14 @@ The criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core itself, Config, Assert, or ThrowException.
* not dependent on any other Boost modules except Core itself, Config, Assert, Static Assert, or Predef.
### Build Status
Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies |
---------|----------------|--------- | ----------- | ------------ |
Develop | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/core/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/75arrvfh5ibryd0p/branch/develop?svg=true)](https://ci.appveyor.com/project/cppalliance/core) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://regression.boost.io/develop/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/core.html)
Master | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/core/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/75arrvfh5ibryd0p/branch/master?svg=true)](https://ci.appveyor.com/project/cppalliance/core) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://regression.boost.io/master/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/core.html)
Develop | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/filesystem/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=develop&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/core.html)
Master | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/filesystem/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/boostorg/core?branch=master&svg=true)](https://ci.appveyor.com/project/pdimov/core) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/core.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/core.html)
### Directories
@@ -24,8 +24,8 @@ Master | [![GitHub Actions](https://github.com/boostorg/core/actions/workflows
### More information
* [Documentation](https://boost.org/libs/core)
* Report bugs by opening issues in this repository. Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
* [Report bugs](https://svn.boost.org/trac/boost/newticket?component=core;version=Boost%20Release%20Branch). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* Submit your patches as pull requests against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt).
### License
+1
View File
@@ -8,6 +8,7 @@ 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
;
+1 -21
View File
@@ -1,32 +1,12 @@
[/
Copyright 2021 Peter Dimov
Copyright 2022-2025 Andrey Semashev
Copyright 2022-2024 Andrey Semashev
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt)
]
[section Revision History]
[section Changes in 1.90.0]
* The implementation of `BOOST_TEST_THROWS` and `BOOST_TEST_NO_THROW` macros defined in
[link core.lightweight_test `boost/core/lightweight_test.hpp`] has been changed to avoid
compiler warnings on some compilers, when the macros are used in `if`/`else` blocks. As
a side effect of this change, the semicolon after the macro is now necessary. ([github_pr 205])
* [link core.data `boost::data`] and [link core.size `boost::size`] are now aliases for `std::data`
and `std::size`, respectively, when the latter are provided by compiler. This resolves potential
ambiguities when both `boost::` and `std::` alternatives are found by the compiler, e.g. as a result
of ADL. ([github_issue 206])
[endsect]
[section Changes in 1.89.0]
* Fixed `bit_ceil` to return 1 for input 0 as per specification. ([github_pr 199])
* Added support for `std::format` to `boost::core::string_view`. ([github_issue 190])
[endsect]
[section Changes in 1.86.0]
* Added a [link core.pointer_in_range `boost/core/pointer_in_range.hpp`] header with a `pointer_in_range`
+1 -1
View File
@@ -37,7 +37,7 @@ criteria for inclusion is that the utility component be:
* simple,
* used by other Boost libraries, and
* not dependent on any other Boost modules except Core
itself, Config, Assert, or ThrowException.
itself, Config, Assert, StaticAssert, or ThrowException.
[endsect]
+1 -1
View File
@@ -38,7 +38,7 @@ and return type use spans.
```
auto sha1(boost::span<const unsigned char> input,
boost::span<unsigned char, SHA_DIGEST_LENGTH> output)
boost::span<unsigned char, SHA_DIGEST_LENGTH> ouput)
{
SHA_CTX context;
SHA1_Init(&context);
+29 -29
View File
@@ -15,8 +15,8 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
#include <boost/config.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <limits>
#include <cstring>
@@ -28,7 +28,7 @@
# pragma intrinsic(_BitScanForward)
# pragma intrinsic(_BitScanReverse)
# if defined(_M_X64) || defined(_M_ARM64)
# if defined(_M_X64)
# pragma intrinsic(_BitScanForward64)
# pragma intrinsic(_BitScanReverse64)
# endif
@@ -80,7 +80,7 @@ BOOST_CONSTEXPR To bit_cast( From const & from ) BOOST_NOEXCEPT
template<class To, class From>
To bit_cast( From const & from ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( sizeof(To) == sizeof(From) );
BOOST_STATIC_ASSERT( sizeof(To) == sizeof(From) );
To to;
std::memcpy( &to, &from, sizeof(To) );
@@ -126,7 +126,7 @@ BOOST_CONSTEXPR inline int countl_impl( boost::ulong_long_type x ) BOOST_NOEXCEP
template<class T>
BOOST_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return boost::core::detail::countl_impl( x );
}
@@ -230,7 +230,7 @@ inline int countl_impl( boost::uint16_t x ) BOOST_NOEXCEPT
#endif
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
#if defined(_MSC_VER) && defined(_M_X64) && 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) || defined(_M_ARM64))
#elif defined(_MSC_VER) && defined(_M_X64)
inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
@@ -296,9 +296,9 @@ inline int countl_impl( boost::uint64_t x ) BOOST_NOEXCEPT
template<class T>
BOOST_CXX14_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_CORE_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
{
@@ -323,7 +323,7 @@ BOOST_CXX14_CONSTEXPR int countl_zero( T x ) BOOST_NOEXCEPT
template<class T>
BOOST_CONSTEXPR int countl_one( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return boost::core::countl_zero( static_cast<T>( ~x ) );
}
@@ -365,7 +365,7 @@ BOOST_CONSTEXPR inline int countr_impl( boost::ulong_long_type x ) BOOST_NOEXCEP
template<class T>
BOOST_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return boost::core::detail::countr_impl( x );
}
@@ -455,7 +455,7 @@ inline int countr_impl( boost::uint16_t x ) BOOST_NOEXCEPT
#endif
#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) && defined(BOOST_CORE_HAS_BUILTIN_ISCONSTEVAL)
#if defined(_MSC_VER) && defined(_M_X64) && 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) || defined(_M_ARM64))
#elif defined(_MSC_VER) && defined(_M_X64)
inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
{
@@ -521,9 +521,9 @@ inline int countr_impl( boost::uint64_t x ) BOOST_NOEXCEPT
template<class T>
BOOST_CXX14_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_CORE_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
{
@@ -548,7 +548,7 @@ BOOST_CXX14_CONSTEXPR int countr_zero( T x ) BOOST_NOEXCEPT
template<class T>
BOOST_CONSTEXPR int countr_one( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return boost::core::countr_zero( static_cast<T>( ~x ) );
}
@@ -598,7 +598,7 @@ BOOST_CORE_POPCOUNT_CONSTEXPR inline int popcount_impl( boost::ulong_long_type x
template<class T>
BOOST_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return boost::core::detail::popcount_impl( x );
}
@@ -631,9 +631,9 @@ BOOST_CXX14_CONSTEXPR inline int popcount_impl( boost::uint64_t x ) BOOST_NOEXCE
template<class T>
BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_CORE_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
{
@@ -652,7 +652,7 @@ BOOST_CXX14_CONSTEXPR int popcount( T x ) BOOST_NOEXCEPT
template<class T>
BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
unsigned const mask = std::numeric_limits<T>::digits - 1;
return static_cast<T>( x << (static_cast<unsigned>( s ) & mask) | x >> (static_cast<unsigned>( -s ) & mask) );
@@ -661,7 +661,7 @@ BOOST_CXX14_CONSTEXPR T rotl( T x, int s ) BOOST_NOEXCEPT
template<class T>
BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
unsigned const mask = std::numeric_limits<T>::digits - 1;
return static_cast<T>( x >> (static_cast<unsigned>( s ) & mask) | x << (static_cast<unsigned>( -s ) & mask) );
@@ -672,7 +672,7 @@ BOOST_CXX14_CONSTEXPR T rotr( T x, int s ) BOOST_NOEXCEPT
template<class T>
BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return x != 0 && ( x & ( x - 1 ) ) == 0;
}
@@ -683,7 +683,7 @@ BOOST_CONSTEXPR bool has_single_bit( T x ) BOOST_NOEXCEPT
template<class T>
BOOST_CONSTEXPR int bit_width( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return std::numeric_limits<T>::digits - boost::core::countl_zero( x );
}
@@ -691,7 +691,7 @@ BOOST_CONSTEXPR int bit_width( T x ) BOOST_NOEXCEPT
template<class T>
BOOST_CONSTEXPR T bit_floor( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
return x == 0? T(0): static_cast<T>( T(1) << ( boost::core::bit_width( x ) - 1 ) );
}
@@ -703,7 +703,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint32_t bit_ceil_impl( boost::uint32_t x )
{
if( x == 0 )
{
return 1;
return 0;
}
--x;
@@ -723,7 +723,7 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x )
{
if( x == 0 )
{
return 1;
return 0;
}
--x;
@@ -745,9 +745,9 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t bit_ceil_impl( boost::uint64_t x )
template<class T>
BOOST_CXX14_CONSTEXPR T bit_ceil( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer && !std::numeric_limits<T>::is_signed );
BOOST_CORE_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
BOOST_STATIC_ASSERT( sizeof(T) <= sizeof(boost::uint64_t) );
BOOST_IF_CONSTEXPR ( sizeof(T) <= sizeof(boost::uint32_t) )
{
@@ -922,9 +922,9 @@ BOOST_CXX14_CONSTEXPR inline boost::uint64_t byteswap_impl( boost::uint64_t x )
template<class T> BOOST_CXX14_CONSTEXPR T byteswap( T x ) BOOST_NOEXCEPT
{
BOOST_CORE_STATIC_ASSERT( std::numeric_limits<T>::is_integer );
BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_integer );
BOOST_CORE_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_STATIC_ASSERT( sizeof(T) == sizeof(boost::uint8_t) || sizeof(T) == sizeof(boost::uint16_t) || sizeof(T) == sizeof(boost::uint32_t) || sizeof(T) == sizeof(boost::uint64_t) );
BOOST_IF_CONSTEXPR ( sizeof(T) == sizeof(boost::uint8_t) )
{
+3 -3
View File
@@ -20,8 +20,8 @@
#if defined(BOOST_CORE_USE_GENERIC_CMATH) || (!defined(_MSC_VER) && !defined(FP_SUBNORMAL))
#include <boost/core/detail/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/static_assert.hpp>
#include <limits>
#include <cstring>
@@ -81,7 +81,7 @@ inline bool signbit( float x )
{
boost::int32_t y;
BOOST_CORE_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
@@ -92,7 +92,7 @@ inline bool signbit( double x )
{
boost::int64_t y;
BOOST_CORE_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
BOOST_STATIC_ASSERT( sizeof( x ) == sizeof( y ) );
std::memcpy( &y, &x, sizeof( y ) );
+1 -15
View File
@@ -8,20 +8,8 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_DATA_HPP
#define BOOST_CORE_DATA_HPP
#include <iterator>
// Note: MSVC doesn't define __cpp_lib_nonmember_container_access but supports the feature even in C++14 mode
#if (defined(__cpp_lib_nonmember_container_access) && (__cpp_lib_nonmember_container_access >= 201411l)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1900))
namespace boost {
using std::data;
} /* boost */
#else // (defined(__cpp_lib_nonmember_container_access) ...
#include <cstddef>
#include <initializer_list>
#include <cstddef>
namespace boost {
@@ -55,6 +43,4 @@ data(std::initializer_list<T> l) noexcept
} /* boost */
#endif // (defined(__cpp_lib_nonmember_container_access) ...
#endif
-1
View File
@@ -10,7 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#include <new>
#include <cstddef>
namespace boost {
+1 -1
View File
@@ -30,7 +30,7 @@
#if defined( BOOST_CORE_HAS_CXXABI_H )
# include <cxxabi.h>
// For some architectures (mips, mips64, x86, x86_64) cxxabi.h in Android NDK is implemented by gabi++ library
// For some archtectures (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
View File
@@ -1,18 +0,0 @@
/*
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
@@ -1,42 +0,0 @@
#ifndef BOOST_CORE_DETAIL_STATIC_ASSERT_HPP_INCLUDED
#define BOOST_CORE_DETAIL_STATIC_ASSERT_HPP_INCLUDED
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__cpp_static_assert) && __cpp_static_assert >= 200410L
#define BOOST_CORE_STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)
#else
#include <boost/config.hpp>
#include <cstddef>
namespace boost
{
namespace core
{
template<bool> struct STATIC_ASSERTION_FAILURE;
template<> struct STATIC_ASSERTION_FAILURE<true>
{
};
template<std::size_t> struct static_assert_test
{
};
} // namespace core
} // namespace boost
#define BOOST_CORE_STATIC_ASSERT(expr) \
typedef ::boost::core::static_assert_test< \
sizeof( ::boost::core::STATIC_ASSERTION_FAILURE<(expr)? true: false> ) \
> BOOST_JOIN(boost_static_assert_typedef_,__LINE__) BOOST_ATTRIBUTE_UNUSED
#endif
#endif // #ifndef BOOST_CORE_DETAIL_STATIC_ASSERT_HPP_INCLUDED
-14
View File
@@ -34,9 +34,6 @@
#if !defined(BOOST_NO_CXX20_HDR_CONCEPTS) // std::common_reference_with
# include <type_traits>
#endif
#if !defined(BOOST_NO_CXX20_HDR_FORMAT)
# include <format> // std::formatter
#endif
namespace boost
{
@@ -1264,15 +1261,4 @@ struct std::basic_common_reference<
#endif
// std::format support
#if !defined(BOOST_NO_CXX20_HDR_FORMAT)
template<class Ch, class Ch2>
struct std::formatter<boost::core::basic_string_view<Ch>, Ch2>: std::formatter<std::basic_string_view<Ch>, Ch2>
{
};
#endif
#endif // #ifndef BOOST_CORE_STRING_VIEW_HPP_INCLUDED
+28 -36
View File
@@ -551,47 +551,39 @@ inline void lwt_init()
#define BOOST_TEST_ALL_EQ(begin1, end1, begin2, end2) ( ::boost::detail::test_all_eq_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2) )
#define BOOST_TEST_ALL_WITH(begin1, end1, begin2, end2, predicate) ( ::boost::detail::test_all_with_impl(BOOST_LIGHTWEIGHT_TEST_OSTREAM, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, begin1, end1, begin2, end2, predicate) )
#if defined(BOOST_MSVC) && BOOST_MSVC < 1900
# define BOOST_LWT_DETAIL_WHILE_FALSE __pragma(warning(push)) __pragma(warning(disable:4127)) while(false) __pragma(warning(pop))
#ifndef BOOST_NO_EXCEPTIONS
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
try { \
EXPR; \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
::boost::detail::test_results(); \
} \
catch(...) { \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
//
#else
# define BOOST_LWT_DETAIL_WHILE_FALSE while(false)
#define BOOST_TEST_THROWS( EXPR, EXCEP )
#endif
#ifndef BOOST_NO_EXCEPTIONS
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
do { \
try { \
EXPR; \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
catch(EXCEP const&) { \
::boost::detail::test_results(); \
} \
catch(...) { \
::boost::detail::throw_failed_impl \
(#EXPR, #EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
} BOOST_LWT_DETAIL_WHILE_FALSE
# define BOOST_TEST_NO_THROW(EXPR) \
try { \
EXPR; \
} catch (const std::exception& e) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} catch (...) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
}
//
#else
#define BOOST_TEST_THROWS( EXPR, EXCEP ) do {} BOOST_LWT_DETAIL_WHILE_FALSE
#endif
#ifndef BOOST_NO_EXCEPTIONS
# define BOOST_TEST_NO_THROW(EXPR) \
do { \
try { \
EXPR; \
} catch (const std::exception& e) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, e.what(), __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} catch (...) { \
::boost::detail::no_throw_failed_impl \
(#EXPR, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
} \
} BOOST_LWT_DETAIL_WHILE_FALSE
#else
# define BOOST_TEST_NO_THROW(EXPR) do { EXPR; } BOOST_LWT_DETAIL_WHILE_FALSE
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
#endif
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
+1 -1
View File
@@ -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 doesn't implicitly convert to the underlying type.
* This function is useful when working with scoped enum classes, which doens't implicitly convert to the underlying type.
* @param v A scoped enum.
* @returns The underlying type.
* @throws No-throws.
-14
View File
@@ -8,18 +8,6 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_SIZE_HPP
#define BOOST_CORE_SIZE_HPP
#include <iterator>
// Note: MSVC doesn't define __cpp_lib_nonmember_container_access but supports the feature even in C++14 mode
#if (defined(__cpp_lib_nonmember_container_access) && (__cpp_lib_nonmember_container_access >= 201411l)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1900))
namespace boost {
using std::size;
} /* boost */
#else // (defined(__cpp_lib_nonmember_container_access) ...
#include <cstddef>
namespace boost {
@@ -40,6 +28,4 @@ size(T(&)[N]) noexcept
} /* boost */
#endif // (defined(__cpp_lib_nonmember_container_access) ...
#endif
+23 -13
View File
@@ -8,12 +8,20 @@ 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 <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <array>
#include <iterator>
#include <type_traits>
#if BOOST_WORKAROUND(BOOST_GCC, < 50000)
# define BOOST_CORE_SPAN_CONSTEXPR
#else
# define BOOST_CORE_SPAN_CONSTEXPR constexpr
#endif
namespace boost {
constexpr std::size_t dynamic_extent = static_cast<std::size_t>(-1);
@@ -274,19 +282,19 @@ public:
return span<T, C>(s_.p + O, C);
}
constexpr span<T, dynamic_extent> first(size_type c) const {
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> first(size_type c) const {
return BOOST_ASSERT(c <= size()),
span<T, dynamic_extent>(s_.p, c);
}
constexpr span<T, dynamic_extent> last(size_type c) const {
return BOOST_CORE_DETAIL_ASSERT(c <= size()),
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> last(size_type c) const {
return BOOST_ASSERT(c <= size()),
span<T, dynamic_extent>(s_.p + (s_.n - c), c);
}
constexpr span<T, dynamic_extent> subspan(size_type o,
BOOST_CORE_SPAN_CONSTEXPR span<T, dynamic_extent> subspan(size_type o,
size_type c = dynamic_extent) const {
return BOOST_CORE_DETAIL_ASSERT(o <= size() &&
return BOOST_ASSERT(o <= size() &&
(c == dynamic_extent || c + o <= size())),
span<T, dynamic_extent>(s_.p + o,
c == dynamic_extent ? s_.n - o : c);
@@ -304,16 +312,16 @@ public:
return s_.n == 0;
}
constexpr reference operator[](size_type i) const {
return BOOST_CORE_DETAIL_ASSERT(i < size()), s_.p[i];
BOOST_CORE_SPAN_CONSTEXPR reference operator[](size_type i) const {
return BOOST_ASSERT(i < size()), s_.p[i];
}
constexpr reference front() const {
return BOOST_CORE_DETAIL_ASSERT(!empty()), *s_.p;
BOOST_CORE_SPAN_CONSTEXPR reference front() const {
return BOOST_ASSERT(!empty()), *s_.p;
}
constexpr reference back() const {
return BOOST_CORE_DETAIL_ASSERT(!empty()), s_.p[s_.n - 1];
BOOST_CORE_SPAN_CONSTEXPR reference back() const {
return BOOST_ASSERT(!empty()), s_.p[s_.n - 1];
}
constexpr pointer data() const noexcept {
@@ -403,4 +411,6 @@ as_writable_bytes(span<T, E> s) noexcept
} /* boost */
#undef BOOST_CORE_SPAN_CONSTEXPR
#endif
-14
View File
@@ -14,7 +14,6 @@ import testing ;
project : requirements
<library>/boost/core//boost_core
<library>/boost/static_assert//boost_static_assert
<library>/boost/type_traits//boost_type_traits
<warnings>extra
<toolset>msvc:<warnings-as-errors>on
@@ -406,9 +405,6 @@ compile sv_construct_test_cx2.cpp ;
run sv_hash_test.cpp : : : $(CPP11) <library>/boost/container_hash//boost_container_hash ;
run sv_format_test.cpp
: : : $(pedantic-errors) ;
run span_test.cpp ;
run span_types_test.cpp ;
run span_constructible_test.cpp ;
@@ -417,7 +413,6 @@ run span_constexpr_test.cpp ;
run as_bytes_test.cpp ;
run as_writable_bytes_test.cpp ;
compile span_boost_begin_test.cpp ;
compile span_nonmem_data_size_test.cpp ;
run make_span_test.cpp ;
run splitmix64_test.cpp
@@ -470,12 +465,3 @@ run minstd_rand_test.cpp
use-project /boost/core/swap : ./swap ;
build-project ./swap ;
compile static_assert_test.cpp ;
compile static_assert_test2.cpp ;
compile static_assert_test3.cpp ;
compile-fail static_assert_fail.cpp ;
compile-fail static_assert_fail2.cpp ;
compile-fail static_assert_fail3.cpp ;
compile-fail static_assert_fail4.cpp ;
+3 -4
View File
@@ -19,15 +19,14 @@ 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, 1 );
BOOST_TEST_EQ( y, 0 );
}
else
{
BOOST_TEST( boost::core::has_single_bit( y ) );
BOOST_TEST_GE( +y, +x );
BOOST_TEST_LT( y >> 1, +x );
}
}
+1
View File
@@ -9,6 +9,7 @@ project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/core)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_subdirectory(../../../static_assert boostorg/static_assert)
add_subdirectory(../../../throw_exception boostorg/throw_exception)
add_executable(quick ../quick.cpp)
-17
View File
@@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/data.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iterator>
class range {
public:
@@ -53,28 +52,12 @@ void test_initializer_list()
BOOST_TEST_EQ(boost::data(l), l.begin());
}
void test_ambiguity_with_std_data()
{
// Note: This preprocessor check should be equivalent to that in boost/core/data.hpp
#if (defined(__cpp_lib_nonmember_container_access) && (__cpp_lib_nonmember_container_access >= 201411l)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1900))
// https://github.com/boostorg/core/issues/206
range c;
using std::data;
using boost::data;
BOOST_TEST_EQ(data(c), c.data());
#endif
}
int main()
{
test_range();
test_const_range();
test_array();
test_initializer_list();
test_ambiguity_with_std_data();
return boost::report_errors();
}
#else
+1 -1
View File
@@ -31,7 +31,7 @@ using std::distance;
*/
// struct C {} doesn't work with libc++.
// struct C {} doesn't wotk with libc++.
typedef std::forward_iterator_tag C;
struct T
-17
View File
@@ -9,7 +9,6 @@ Distributed under the Boost Software License, Version 1.0.
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/size.hpp>
#include <boost/core/lightweight_test.hpp>
#include <iterator>
struct range {
std::size_t size() const {
@@ -29,26 +28,10 @@ void test_array()
BOOST_TEST_EQ(boost::size(a), 4);
}
void test_ambiguity_with_std_size()
{
// Note: This preprocessor check should be equivalent to that in boost/core/size.hpp
#if (defined(__cpp_lib_nonmember_container_access) && (__cpp_lib_nonmember_container_access >= 201411l)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1900))
// https://github.com/boostorg/core/issues/206
range c;
using std::size;
using boost::size;
BOOST_TEST_EQ(size(c), c.size());
#endif
}
int main()
{
test_range();
test_array();
test_ambiguity_with_std_size();
return boost::report_errors();
}
#else
+2 -1
View File
@@ -6,7 +6,8 @@ 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/config/workaround.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 50000)
#include <boost/core/span.hpp>
#include <boost/core/lightweight_test.hpp>
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright Andrey Semashev 2025.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*
* The test verifies that unqualified calls to data() and size()
* don't cause ambiguity between std:: and boost:: implementations.
* The ambiguity used to be caused by ADL bringing boost::data()/size()
* due to namespace of boost::span and a using-declaration of
* std::data()/size().
*
* https://github.com/boostorg/core/issues/206
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/span.hpp>
#include <iterator>
// Note: This preprocessor check should be equivalent to those in boost/core/data.hpp and boost/core/size.hpp
#if (defined(__cpp_lib_nonmember_container_access) && (__cpp_lib_nonmember_container_access >= 201411l)) || \
(defined(_MSC_VER) && (_MSC_VER >= 1900))
#include <boost/core/data.hpp>
#include <boost/core/size.hpp>
int* test_data_ambiguity(boost::span<int> sp)
{
using std::data;
return data(sp);
}
boost::span<int>::size_type test_size_ambiguity(boost::span<int> sp)
{
using std::size;
return size(sp);
}
#endif // (defined(__cpp_lib_nonmember_container_access) ...
#endif // !defined(BOOST_NO_CXX11_CONSTEXPR) && !defined(BOOST_NO_CXX11_DECLTYPE)
-11
View File
@@ -1,11 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
BOOST_CORE_STATIC_ASSERT( sizeof(char[1]) != 1 );
int main()
{
}
-14
View File
@@ -1,14 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
struct X
{
BOOST_CORE_STATIC_ASSERT( sizeof(char[2]) != 2 );
};
int main()
{
}
-10
View File
@@ -1,10 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
int main()
{
BOOST_CORE_STATIC_ASSERT( sizeof(char[3]) != 3 );
}
-16
View File
@@ -1,16 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
template<int C> struct X
{
BOOST_CORE_STATIC_ASSERT( C >= 0 );
};
int main()
{
X< -4 > x;
(void)x;
}
-17
View File
@@ -1,17 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
BOOST_CORE_STATIC_ASSERT( sizeof(char[1]) == 1 );
struct X
{
BOOST_CORE_STATIC_ASSERT( sizeof(char[2]) == 2 );
};
int main()
{
BOOST_CORE_STATIC_ASSERT( sizeof(char[3]) == 3 );
}
-25
View File
@@ -1,25 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
template<int A, int B> struct plus
{
static const int value = A + B;
};
BOOST_CORE_STATIC_ASSERT((plus<1, 2>::value == 3));
template<int C> struct X
{
BOOST_CORE_STATIC_ASSERT((plus<C, 1>::value == C + 1));
};
int main()
{
BOOST_CORE_STATIC_ASSERT((plus<3, 4>::value == 7));
X<4> x;
(void)x;
}
-16
View File
@@ -1,16 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/static_assert.hpp>
template<int C> struct X
{
BOOST_CORE_STATIC_ASSERT( C >= 0 );
};
int main()
{
X<4> x;
(void)x;
}
-30
View File
@@ -1,30 +0,0 @@
// Copyright 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
#if !( defined(__cpp_lib_format) && __cpp_lib_format >= 201907L )
BOOST_PRAGMA_MESSAGE( "Test skipped because __cpp_lib_format is not defined to at least 201907L" )
int main() {}
#else
#include <format>
#include <string_view>
int main()
{
BOOST_TEST_EQ( std::format( "{}", boost::core::string_view( "123" ) ), std::format( "{}", std::string_view( "123" ) ) );
BOOST_TEST_EQ( std::format( "{:s}", boost::core::string_view( "123" ) ), std::format( "{:s}", std::string_view( "123" ) ) );
BOOST_TEST_EQ( std::format( "{:^7}", boost::core::string_view( "123" ) ), std::format( "{:^7}", std::string_view( "123" ) ) );
BOOST_TEST_EQ( std::format( "{:-^7}", boost::core::string_view( "123" ) ), std::format( "{:-^7}", std::string_view( "123" ) ) );
return boost::report_errors();
}
#endif
+1 -1
View File
@@ -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 arguments, thereby making it less specialized
// boost::core::invoke_swap two template argumetns, thereby making it less specialized
// than std::swap.
#include <boost/core/invoke_swap.hpp>
+1 -1
View File
@@ -12,7 +12,7 @@
//Put test class in the global namespace
#include "./swap_test_class.hpp"
//Provide swap function in global namespace
//Provide swap function in gloabl namespace
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);