Compare commits

...

23 Commits

Author SHA1 Message Date
Peter Dimov 7b2c714b55 Disable warning 4127 under msvc-12.0 and earlier 2025-10-20 20:58:49 +03:00
Peter Dimov 4777321ff2 Revert "Omit do {} while (false) for MSVC versions prior to 2015"
This reverts commit 40fda50ae1.
2025-10-20 20:27:17 +03:00
Peter Dimov d5a57eb725 Increase timeout in ci.yml for macos-13 2025-10-20 06:11:34 +03:00
Peter Dimov fb34afaabd Correct CMake version check; VERSION_GREATER 3.18 is true for 3.18.1 2025-10-20 02:10:33 +03:00
Andrey Semashev e8fdc407bd Added a changelog entry for the lightweight_test.hpp change.
Refs https://github.com/boostorg/core/pull/205.
2025-10-19 22:14:36 +03:00
Andrey Semashev 64093058de Added a changelog entry for the boost::data/size change. 2025-10-19 22:08:39 +03:00
Andrey Semashev 3cd29323be Add a test for boost::span verifying unqualified calls to data()/size().
The test checks that unqualified calls to data()/size() with boost::span
as argument don't cause ambiguity between std:: and boost:: implementations.

Fixes https://github.com/boostorg/core/issues/206.
2025-10-19 21:56:04 +03:00
Andrey Semashev 45bd9bf69b Use std::data and std::size for boost equivalents, when possible.
This avoids the potential ambiguity between boost:: and std:: functions
when the user calls data() or size() unqualified and both alternatives
are found via ADL.

Refs https://github.com/boostorg/core/issues/206.
2025-10-19 21:56:04 +03:00
Peter Dimov 6814bc508c Merge pull request #205 from gennaroprota/fix/use_do_while_false_for_boost_test_throws_and_boost_test_no_throw
Use the do {} while (false) idiom for BOOST_TEST_THROWS() and BOOST_TEST_NO_THROW()
2025-10-18 16:06:01 +03:00
Gennaro Prota 40fda50ae1 Omit do {} while (false) for MSVC versions prior to 2015
Reason: See the new code comment.
2025-10-15 12:30:48 +02:00
Gennaro Prota 8a352e253a Use the do {} while (false) idiom for BOOST_TEST_THROWS() and BOOST_TEST_NO_THROW()
Reason: Common hygiene for multi-line macros. Makes things like

if (condition)
    BOOST_TEST_THROWS(...);
else
    ...

work correctly. Also, it doesn't generate an empty statement (which
compilers may warn about) when the user adds a semicolon (which they
usually do).
2025-10-09 19:00:47 +02:00
Andrey Semashev c6b098d25d Merge pull request #201 from Flamefire/test-link-update
Update Link to regression test matrix in README
2025-08-25 19:05:15 +03:00
Alexander Grund c4bfbf9ec5 Update Link to regression test matrix in README 2025-08-25 17:26:11 +02:00
Peter Dimov a128501403 Update revision history 2025-06-30 13:06:07 +03:00
Peter Dimov 24b5bb625e Update .drone.jsonnet 2025-06-25 20:26:52 +03:00
Peter Dimov d513ed162a Update .drone.jsonnet 2025-06-25 19:28:05 +03:00
Peter Dimov 65337d1af8 Add a std::formatter specialization for core::string_view. Fixes #190. 2025-06-25 17:11:26 +03:00
Peter Dimov 16d8f5f8ff Add sv_format_test.cpp. Refs #190. 2025-06-25 16:51:59 +03:00
Andrey Semashev 58f469cd80 Added ARM jobs in GitHub Actions. 2025-06-13 02:30:14 +03:00
Andrey Semashev 457d6a8ad0 Use Azure mirrors of Ubuntu .deb repositories in containers.
This reduces the likelihood of spurious CI failures caused by DDoS filters
being triggered by massive numbers of concurrent CI jobs.
2025-06-13 02:23:02 +03:00
Andrey Semashev e3d8de377b Removed windows-2019 jobs from GitHub Actions.
The windows-2019 image is deprecated and is about to be removed.

https://github.com/actions/runner-images/issues/12045
2025-06-13 02:21:12 +03:00
Peter Dimov 8d25b9ce54 Add missing include 2025-06-06 21:47:38 +03:00
Peter Dimov 6e05e5e764 Update ci.yml 2025-06-06 21:00:18 +03:00
15 changed files with 297 additions and 60 deletions
+25 -12
View File
@@ -34,7 +34,6 @@ 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 []) +
@@ -235,6 +234,13 @@ 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",
@@ -369,26 +375,33 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
),
linux_pipeline(
"Linux 24.04 Clang 18 UBSAN",
"Linux 24.04 Clang 18",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' },
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 18 ASAN",
"Linux 24.04 Clang 19 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '03,11,14,17,20,2b' } + asan,
"clang-18",
),
linux_pipeline(
"Linux 24.10 Clang 19",
"cppalliance/droneubuntu2410:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' },
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 19 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '03,11,14,17,20,2b' } + asan,
"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,
+56 -15
View File
@@ -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)
@@ -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"
@@ -318,13 +325,24 @@ jobs:
compiler: clang++-19
cxxstd: "03,11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.10
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
@@ -338,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
@@ -365,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
@@ -565,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
@@ -584,10 +618,17 @@ 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
timeout-minutes: 60
steps:
- name: Setup Boost
@@ -862,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
@@ -924,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
@@ -1004,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
+1 -1
View File
@@ -20,7 +20,7 @@ target_link_libraries(boost_core
Boost::throw_exception
)
if(CMAKE_VERSION VERSION_GREATER 3.18 AND CMAKE_GENERATOR MATCHES "Visual Studio")
if(NOT CMAKE_VERSION VERSION_LESS 3.19 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")
+2 -2
View File
@@ -12,8 +12,8 @@ The criteria for inclusion is that the utility component be:
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/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)
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)](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/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)](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)
### Directories
+21 -1
View File
@@ -1,12 +1,32 @@
[/
Copyright 2021 Peter Dimov
Copyright 2022-2024 Andrey Semashev
Copyright 2022-2025 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`
+15 -1
View File
@@ -8,8 +8,20 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_DATA_HPP
#define BOOST_CORE_DATA_HPP
#include <initializer_list>
#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>
namespace boost {
@@ -43,4 +55,6 @@ data(std::initializer_list<T> l) noexcept
} /* boost */
#endif // (defined(__cpp_lib_nonmember_container_access) ...
#endif
+1
View File
@@ -10,6 +10,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/config.hpp>
#include <new>
#include <cstddef>
namespace boost {
+14
View File
@@ -34,6 +34,9 @@
#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
{
@@ -1261,4 +1264,15 @@ 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
+36 -28
View File
@@ -551,39 +551,47 @@ 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) )
#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); \
} \
//
#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))
#else
#define BOOST_TEST_THROWS( EXPR, EXCEP )
# define BOOST_LWT_DETAIL_WHILE_FALSE while(false)
#endif
#ifndef BOOST_NO_EXCEPTIONS
# 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); \
}
//
#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
#else
# define BOOST_TEST_NO_THROW(EXPR) { EXPR; }
#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
#endif
#endif // #ifndef BOOST_CORE_LIGHTWEIGHT_TEST_HPP
+14
View File
@@ -8,6 +8,18 @@ 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 {
@@ -28,4 +40,6 @@ size(T(&)[N]) noexcept
} /* boost */
#endif // (defined(__cpp_lib_nonmember_container_access) ...
#endif
+4
View File
@@ -405,6 +405,9 @@ 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 ;
@@ -413,6 +416,7 @@ 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
+17
View File
@@ -9,6 +9,7 @@ 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:
@@ -52,12 +53,28 @@ 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
+17
View File
@@ -9,6 +9,7 @@ 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 {
@@ -28,10 +29,26 @@ 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
+44
View File
@@ -0,0 +1,44 @@
/*
* 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)
+30
View File
@@ -0,0 +1,30 @@
// 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