1
0
forked from boostorg/core

Compare commits

...

67 Commits

Author SHA1 Message Date
Peter Dimov
5904fb5636 Disable call to ::_seterrormode when WINAPI_FAMILY is defined to something other than WINAPI_FAMILY_DESKTOP_APP. Refs #143. 2023-04-15 19:36:12 +03:00
Glen Fernandes
39978bde2b Add note about identity being moved from functional 2023-02-24 00:19:13 -05:00
Glen Fernandes
d5fa9ae50f Fix and update documentation and release notes 2023-02-24 00:16:56 -05:00
Peter Dimov
2814b4ca1c Update documentation 2023-02-22 20:18:01 +02:00
Glen Fernandes
c4e420f69d Use boost::data in boost::span 2023-02-22 09:40:54 -05:00
Peter Dimov
94628cb2f9 Use undefined-sanitizer=norecover instead of cxxflags 2023-02-21 17:47:38 +02:00
Peter Dimov
19f9aa93e1 Merge branch 'feature/drone' into develop 2023-02-21 07:58:29 +02:00
Peter Dimov
2691efd1ca Re-disable serialization_nvp_test under UBSan; link=static doesn't help there 2023-02-21 06:29:10 +02:00
Peter Dimov
b6b1498275 Use link=static instead of visibility=global (which doesn't help) 2023-02-21 06:11:44 +02:00
Glen Fernandes
379899ef15 Move identity from functional to core 2023-02-20 23:02:30 -05:00
Peter Dimov
3ab949d321 Only use visibility=global in UBSan builds 2023-02-21 05:32:28 +02:00
Peter Dimov
dbf0ea98b9 Add visibility=global to serialization tests because of UBSan; disable serialization_nvp_test for GCC/UBSan as well 2023-02-21 05:25:20 +02:00
Peter Dimov
5afc91d52d Change _EQ(max_align, alignof(std::max_align_t)) to _GE unconditionally, because macOS 12.4/M1 also fails (16 > 8) 2023-02-21 05:23:43 +02:00
Peter Dimov
f2a1532105 Add macOS 12.4 (M1) to Drone 2023-02-21 04:55:39 +02:00
Peter Dimov
64e59db1f6 Update serialization_construct_data_test 2023-02-21 02:39:49 +02:00
Peter Dimov
ceb4fff8fc Avoid missing braces warning in serialization_construct_data_test 2023-02-21 02:23:52 +02:00
Peter Dimov
0be25e19cc Add load_construct_data_adl, save_construct_data_adl 2023-02-21 02:04:39 +02:00
Peter Dimov
6debbeb377 Disable serialization_nvp_test under Clang/UBSan 2023-02-21 01:34:35 +02:00
Peter Dimov
4b859e3d39 Use friend class, omission of class is C++11 2023-02-20 21:17:55 +02:00
Peter Dimov
38037b45f1 Add boost::core::split_member 2023-02-20 21:00:26 +02:00
Peter Dimov
7664d7ab7e Disable -Wdeprecated-copy in serialization_*_test 2023-02-20 20:39:03 +02:00
Peter Dimov
20d89b69db Add missing initializers to avoid warnings from GCC 4.x 2023-02-20 20:19:59 +02:00
Peter Dimov
89c5a78129 Add boost/core/serialization.hpp, serialization_nvp_test, serialization_split_free_test 2023-02-20 20:06:19 +02:00
Glen Fernandes
249c5bece2 Implement data and size functions 2023-02-17 15:27:36 -05:00
Glen Fernandes
8977da6f50 Update documentation 2023-01-30 16:19:31 -05:00
Glen Fernandes
edc0d935c0 Implement make_span 2023-01-28 13:07:33 -05:00
Glen Fernandes
7736b0b8ce span support for initializer_list 2023-01-28 12:20:59 -05:00
Peter Dimov
90231ed7e0 Document boost::core::memory_resource 2023-01-27 02:42:10 +02:00
Peter Dimov
1aa287e413 Avoid the inclusion of <new> 2023-01-26 19:37:46 +02:00
Peter Dimov
8c65a5b0e8 Work around g++ 4.6 failure 2023-01-26 19:18:44 +02:00
Peter Dimov
99515c341e Add boost::core::memory_resource 2023-01-26 18:09:35 +02:00
Peter Dimov
42b3a3f111 Use BOOST_CORE_ALIGNOF in boost/core/max_align.hpp 2023-01-26 03:17:05 +02:00
Peter Dimov
c092532a71 Merge branch 'develop' into feature/max-align 2023-01-26 03:06:45 +02:00
Peter Dimov
f6193acbdf Document BOOST_CORE_ALIGNOF 2023-01-26 03:01:01 +02:00
Peter Dimov
a504b356d4 Merge branch 'develop' into feature/alignof 2023-01-26 02:02:00 +02:00
Peter Dimov
bd1835f92f Avoid memory leak in alloc_construct_cxx11_test.cpp, because ASan diagnoses it 2023-01-26 01:10:00 +02:00
Peter Dimov
bfad92e307 Add Drone support 2023-01-25 22:00:41 +02:00
Peter Dimov
ce93055f03 Disable failing tests under g++ -m32 2023-01-25 21:37:26 +02:00
Peter Dimov
39cf1e65a3 Add BOOST_CORE_ALIGNOF 2023-01-25 20:10:31 +02:00
Peter Dimov
3edd3aa982 Define and use BOOST_CORE_HAS_FLOAT128 2023-01-25 19:38:20 +02:00
Peter Dimov
c704d8b630 Document boost/core/max_align.hpp 2023-01-25 19:02:03 +02:00
Peter Dimov
579a658129 Update max_align_test.cpp 2023-01-25 18:56:37 +02:00
Peter Dimov
4c7f35613e Merge branch 'develop' into feature/max-align 2023-01-25 04:39:27 +02:00
Peter Dimov
642a0cf70e Update ci.yml 2023-01-25 01:56:57 +02:00
Peter Dimov
ece7a9ad9c Update max_align_test.cpp 2023-01-25 01:52:18 +02:00
Peter Dimov
5632ee0367 Test __SIZEOF_FLOAT128__ as well, for g++ -m32 2023-01-25 01:41:01 +02:00
Peter Dimov
8052abb15c Add boost::core::max_align(_t) 2023-01-24 21:06:07 +02:00
Peter Dimov
d3ed836f75 Document boost::core::launder 2023-01-24 19:40:30 +02:00
Peter Dimov
c4777c309e Avoid including <new> in core/launder.hpp when not C++17 2023-01-24 18:54:45 +02:00
Peter Dimov
2b3b97c633 Add boost::core::launder 2023-01-24 17:50:45 +02:00
Peter Dimov
ab455ab2f8 Disable -Wdeprecated-declarations for early clang-cl 2023-01-23 05:24:28 +02:00
Peter Dimov
116c6830e0 Add VS2017 clang-cl to Appveyor 2023-01-23 04:13:05 +02:00
Peter Dimov
d8cfc71073 lwt_unattended: disable WER dialog box on crash 2023-01-19 02:35:15 +02:00
Peter Dimov
dd85ed565e Update CMakeLists.txt 2023-01-12 20:53:52 +02:00
Peter Dimov
58fd395c51 Merge branch 'develop' of https://github.com/vinniefalco/boost-core into feature/pr-122 2023-01-12 20:51:58 +02:00
Peter Dimov
992824c50b Update appveyor.yml 2023-01-12 19:55:57 +02:00
Peter Dimov
9d443cb094 Update appveyor.yml 2023-01-12 18:44:30 +02:00
Peter Dimov
7d67301bba Add CMake tests to Appveyor 2023-01-12 15:25:51 +02:00
Peter Dimov
e487fec094 Merge branch 'develop' into feature/appveyor 2023-01-12 15:23:02 +02:00
Andrey Semashev
0890785fec Added #pragma once in swap.hpp. 2023-01-07 03:52:46 +03:00
Andrey Semashev
eda68d4086 Trim trailing spaces in boost::swap tests. 2023-01-07 03:42:31 +03:00
Andrey Semashev
8a8738a981 Propagate noexcept specification in boost::swap.
Mark boost::swap noexcept if the type supports non-throwing swap
implementation.
2023-01-07 03:42:15 +03:00
Andrey Semashev
99f9654f18 Fixed incorrect preprocessor condition for ref_empty definition.
Closes https://github.com/boostorg/core/pull/137.
2023-01-07 01:06:41 +03:00
Andrey Semashev
1e84baeea3 Use defaulted template arguments to restrict boost::ref converting ctor. 2023-01-06 19:38:55 +03:00
Andrey Semashev
1825265014 Marked boost::ref methods and associated functions with noexcept. 2023-01-06 19:12:47 +03:00
Vinnie Falco
6fb57488a2 add boost_core.natvis and interface project sources 2022-08-19 12:18:32 -07:00
Peter Dimov
003c7365bc Use VS2019 for clang-win, because VS2017 fails to find msvcrt(d).lib for some reason now 2021-10-05 01:00:09 +03:00
68 changed files with 3066 additions and 121 deletions

382
.drone.jsonnet Normal file
View File

@@ -0,0 +1,382 @@
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
local library = "core";
local triggers =
{
branch: [ "master", "develop", "feature/*" ]
};
local ubsan = { UBSAN: '1', UBSAN_OPTIONS: 'print_stacktrace=1' };
local asan = { ASAN: '1' };
local linux_pipeline(name, image, environment, packages = "", sources = [], arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "linux",
arch: arch
},
steps:
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'set -e',
'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 []) +
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local macos_pipeline(name, environment, xcode_version = "12.2", osx_version = "catalina", arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "exec",
trigger: triggers,
platform: {
"os": "darwin",
"arch": arch
},
node: {
"os": osx_version
},
steps: [
{
name: "everything",
environment: environment + { "DEVELOPER_DIR": "/Applications/Xcode-" + xcode_version + ".app/Contents/Developer" },
commands:
[
'export LIBRARY=' + library,
'./.drone/drone.sh',
]
}
]
};
local windows_pipeline(name, image, environment, arch = "amd64") =
{
name: name,
kind: "pipeline",
type: "docker",
trigger: triggers,
platform:
{
os: "windows",
arch: arch
},
"steps":
[
{
name: "everything",
image: image,
environment: environment,
commands:
[
'cmd /C .drone\\\\drone.bat ' + library,
]
}
]
};
[
linux_pipeline(
"Linux 14.04 GCC 4.4",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.4', CXXSTD: '98,0x' },
"g++-4.4",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.6 32/64",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.6', CXXSTD: '98,0x', ADDRMD: '32,64' },
"g++-4.6-multilib",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.7 32/64",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.7', CXXSTD: '98,0x', ADDRMD: '32,64' },
"g++-4.7-multilib",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 14.04 GCC 4.8* 32/64",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 14.04 GCC 4.9 32/64",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '03,11', ADDRMD: '32,64' },
"g++-4.9-multilib",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 16.04 GCC 5* 32/64",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 18.04 GCC 6 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '03,11,14', ADDRMD: '32,64' },
"g++-6-multilib",
),
linux_pipeline(
"Linux 18.04 GCC 7* 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 18.04 GCC 8 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '03,11,14,17', ADDRMD: '32,64' },
"g++-8-multilib",
),
linux_pipeline(
"Linux 20.04 GCC 9* 32/64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 20.04 GCC 9* ARM64",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
arch="arm64",
),
linux_pipeline(
"Linux 20.04 GCC 9* S390x",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a' },
arch="s390x",
),
linux_pipeline(
"Linux 20.04 GCC 10 32/64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '03,11,14,17,20', ADDRMD: '32,64' },
"g++-10-multilib",
),
linux_pipeline(
"Linux 22.04 GCC 11* 32/64",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '03,11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 22.04 GCC 12 32 ASAN",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '32' } + asan,
"g++-12-multilib",
),
linux_pipeline(
"Linux 22.04 GCC 12 64 ASAN",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '03,11,14,17,20,2b', ADDRMD: '64' } + asan,
"g++-12-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '03,11' },
"clang-3.5",
),
linux_pipeline(
"Linux 16.04 Clang 3.6",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '03,11,14' },
"clang-3.6",
),
linux_pipeline(
"Linux 16.04 Clang 3.7",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '03,11,14' },
"clang-3.7",
),
linux_pipeline(
"Linux 16.04 Clang 3.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '03,11,14' },
"clang-3.8",
),
linux_pipeline(
"Linux 18.04 Clang 3.9",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '03,11,14' },
"clang-3.9",
),
linux_pipeline(
"Linux 18.04 Clang 4.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '03,11,14' },
"clang-4.0",
),
linux_pipeline(
"Linux 18.04 Clang 5.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '03,11,14,1z' },
"clang-5.0",
),
linux_pipeline(
"Linux 18.04 Clang 6.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '03,11,14,17' },
"clang-6.0",
),
linux_pipeline(
"Linux 20.04 Clang 7",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '03,11,14,17' },
"clang-7",
),
linux_pipeline(
"Linux 20.04 Clang 8",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '03,11,14,17' },
"clang-8",
),
linux_pipeline(
"Linux 20.04 Clang 9",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '03,11,14,17,2a' },
"clang-9",
),
linux_pipeline(
"Linux 20.04 Clang 10",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '03,11,14,17,2a' },
"clang-10",
),
linux_pipeline(
"Linux 20.04 Clang 11",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '03,11,14,17,2a' },
"clang-11",
),
linux_pipeline(
"Linux 20.04 Clang 12",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '03,11,14,17,2a' },
"clang-12",
),
linux_pipeline(
"Linux 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '03,11,14,17,20' },
"clang-13",
),
linux_pipeline(
"Linux 22.04 Clang 14 UBSAN",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
"clang-14",
),
linux_pipeline(
"Linux 22.04 Clang 14 ASAN",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '03,11,14,17,20,2b' } + asan,
"clang-14",
),
linux_pipeline(
"Linux 22.04 Clang 15",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '03,11,14,17,20,2b' },
"clang-15",
["deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main"],
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + ubsan,
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,1z' } + asan,
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + ubsan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '03,11,14,17,20,2b' } + asan,
xcode_version = "13.4.1", osx_version = "monterey", arch = "arm64",
),
windows_pipeline(
"Windows VS2015 msvc-14.0",
"cppalliance/dronevs2015",
{ TOOLSET: 'msvc-14.0', CXXSTD: '14,latest' },
),
windows_pipeline(
"Windows VS2017 msvc-14.1",
"cppalliance/dronevs2017",
{ TOOLSET: 'msvc-14.1', CXXSTD: '14,17,latest' },
),
windows_pipeline(
"Windows VS2019 msvc-14.2",
"cppalliance/dronevs2019",
{ TOOLSET: 'msvc-14.2', CXXSTD: '14,17,20,latest' },
),
windows_pipeline(
"Windows VS2022 msvc-14.3",
"cppalliance/dronevs2022:1",
{ TOOLSET: 'msvc-14.3', CXXSTD: '14,17,20,latest' },
),
]

23
.drone/drone.bat Normal file
View File

@@ -0,0 +1,23 @@
@REM Copyright 2022 Peter Dimov
@REM Distributed under the Boost Software License, Version 1.0.
@REM https://www.boost.org/LICENSE_1_0.txt
@ECHO ON
set LIBRARY=%1
set DRONE_BUILD_DIR=%CD%
set BOOST_BRANCH=develop
if "%DRONE_BRANCH%" == "master" set BOOST_BRANCH=master
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
xcopy /s /e /q %DRONE_BUILD_DIR% libs\%LIBRARY%\
python tools/boostdep/depinst/depinst.py -I examples %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
b2 -j3 libs/%LIBRARY%/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker

25
.drone/drone.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
set -ex
export PATH=~/.local/bin:/usr/local/bin:$PATH
DRONE_BUILD_DIR=$(pwd)
BOOST_BRANCH=develop
if [ "$DRONE_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
git submodule update --init tools/boostdep
cp -r $DRONE_BUILD_DIR/* libs/$LIBRARY
python tools/boostdep/depinst/depinst.py -I examples $LIBRARY
./bootstrap.sh
./b2 -d0 headers
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
./b2 -j3 libs/$LIBRARY/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+undefined-sanitizer=norecover debug-symbols=on} ${ASAN:+address-sanitizer=norecover debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}

View File

@@ -32,82 +32,95 @@ jobs:
# Linux, gcc
- toolset: gcc-4.4
cxxstd: "98,0x"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.4
- g++-4.4-multilib
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.6
cxxstd: "03,0x"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.6
- g++-4.6-multilib
sources:
- "ppa:ubuntu-toolchain-r/test"
- toolset: gcc-4.7
cxxstd: "03,11"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.7
- g++-4.7-multilib
- toolset: gcc-4.8
cxxstd: "03,11"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-4.8
- g++-4.8-multilib
- toolset: gcc-4.9
cxxstd: "03,11"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-4.9
- g++-4.9-multilib
- toolset: gcc-5
cxxstd: "03,11,14,1z"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:16.04
install:
- g++-5
- g++-5-multilib
- toolset: gcc-6
cxxstd: "03,11,14,1z"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-6
- g++-6-multilib
- toolset: gcc-7
cxxstd: "03,11,14,17"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-7
- g++-7-multilib
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
address-model: 32,64
os: ubuntu-latest
container: ubuntu:18.04
install:
- g++-8
- g++-8-multilib
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
address-model: 32,64
os: ubuntu-20.04
install:
- g++-9
- g++-9-multilib
- toolset: gcc-10
cxxstd: "03,11,14,17,20"
address-model: 32,64
os: ubuntu-20.04
install:
- g++-10
- g++-10-multilib
- toolset: gcc-11
cxxstd: "03,11,14,17,20,23"
address-model: 32,64
os: ubuntu-22.04
install:
- g++-11
- g++-11-multilib
- toolset: gcc-12
cxxstd: "03,11,14,17,20,23"
address-model: 32,64
os: ubuntu-22.04
install:
- g++-12
- g++-12-multilib
- name: UBSAN
toolset: gcc-12
cxxstd: "03,11,14,17,20,23"
@@ -266,6 +279,9 @@ jobs:
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-11
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-12
timeout-minutes: 120
runs-on: ${{matrix.os}}
@@ -450,12 +466,16 @@ jobs:
if [ -n "${{matrix.ubsan}}" ]
then
export UBSAN_OPTIONS="print_stacktrace=1"
B2_ARGS+=("cxxflags=-fsanitize=undefined -fno-sanitize-recover=undefined" "linkflags=-fsanitize=undefined -fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
B2_ARGS+=("undefined-sanitizer=norecover" "linkflags=-fuse-ld=gold" "define=UBSAN=1" "debug-symbols=on" "visibility=global")
fi
if [ -n "${{matrix.cxxflags}}" ]
then
B2_ARGS+=("cxxflags=${{matrix.cxxflags}}")
fi
if [ -n "${{matrix.address-model}}" ]
then
B2_ARGS+=("address-model=${{matrix.address-model}}")
fi
if [ -n "${{matrix.linkflags}}" ]
then
B2_ARGS+=("linkflags=${{matrix.linkflags}}")
@@ -530,6 +550,7 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
runs-on: ${{matrix.os}}
@@ -576,6 +597,7 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
runs-on: ${{matrix.os}}
@@ -632,6 +654,7 @@ jobs:
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: macos-11
- os: macos-12
runs-on: ${{matrix.os}}

View File

@@ -20,6 +20,15 @@ target_link_libraries(boost_core
Boost::throw_exception
)
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")
list(APPEND boost_core_IDEFILES extra/boost_core.natvis)
target_sources(boost_core PRIVATE ${boost_core_IDEFILES})
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)

View File

@@ -29,6 +29,11 @@ environment:
# clang-win 32 bit fails to link with "unable to load mspdbcore.dll (error code: 126)"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: clang-win
ADDRMD: 64
CXXSTD: 14,17,latest
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
ADDRMD: 64
@@ -59,6 +64,13 @@ environment:
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
CMAKE: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_SUBDIR: 1
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
CMAKE_INSTALL: 1
install:
- set GIT_FETCH_JOBS=8
- set BOOST_BRANCH=develop
@@ -70,7 +82,7 @@ install:
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\core\
- python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" core
- cmd /c bootstrap
- b2 headers
- b2 -d0 headers
build: off
@@ -78,4 +90,27 @@ test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
- if "%CMAKE%%CMAKE_SUBDIR%%CMAKE_INSTALL%" == "" b2 -j %NUMBER_OF_PROCESSORS% libs/core/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
- if not "%CMAKE%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE%" == "" cmake -DBUILD_TESTING=ON -DBOOST_INCLUDE_LIBRARIES=core ..
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Debug & ctest --output-on-failure --no-tests=error -j 3 -C Debug
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config Release & ctest --output-on-failure --no-tests=error -j 3 -C Release
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config MinSizeRel & ctest --output-on-failure --no-tests=error -j 3 -C MinSizeRel
- if not "%CMAKE%" == "" cmake --build . --target tests -j 3 --config RelWithDebInfo & ctest --output-on-failure --no-tests=error -j 3 -C RelWithDebInfo
- if not "%CMAKE_SUBDIR%" == "" cd libs/core/test/cmake_subdir_test && mkdir __build__ && cd __build__
- if not "%CMAKE_SUBDIR%" == "" cmake ..
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config Release && cmake --build . --target check --config Release
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config MinSizeRel && cmake --build . --target check --config MinSizeRel
- if not "%CMAKE_SUBDIR%" == "" cmake --build . --config RelWithDebInfo && cmake --build . --target check --config RelWithDebInfo
- if not "%CMAKE_INSTALL%" == "" mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DBOOST_INCLUDE_LIBRARIES=core -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --target install --config Release
- if not "%CMAKE_INSTALL%" == "" cd ../libs/core/test/cmake_install_test && mkdir __build__ && cd __build__
- if not "%CMAKE_INSTALL%" == "" cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Debug && cmake --build . --target check --config Debug
- if not "%CMAKE_INSTALL%" == "" cmake --build . --config Release && cmake --build . --target check --config Release

33
doc/alignof.qbk Normal file
View File

@@ -0,0 +1,33 @@
[/
Copyright 2023 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:alignof alignof]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/alignof.hpp>]
The header `<boost/core/alignof.hpp>` defines the macro `BOOST_CORE_ALIGNOF`,
a portable equivalent of the `alignof` operator from C++11.
[section Example]
``
#include <boost/core/alignof.hpp>
#include <cstddef>
constexpr std::size_t alignment_of_double = BOOST_CORE_ALIGNOF(double);
``
[endsect]
[endsect]
[endsect]

View File

@@ -14,6 +14,23 @@
* Deprecated `boost/core/is_same.hpp` and `boost::core::is_same`. The header will be removed in a future release.
Users are advised to use [@http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/index.html Boost.TypeTraits]
or C++ standard library type traits instead.
* Marked `boost::ref` member functions and associated methods with `noexcept`.
* Marked `boost::swap` function with `noexcept`, depending on whether the type supports a non-throwing swap operation.
* Added [link core.launder `boost::core::launder`], a portable implementation of `std::launder`.
* Added [link core.alignof `BOOST_CORE_ALIGNOF`], a portable implementation of `alignof`.
* Added [link core.max_align `boost::core::max_align_t`], a portable equivalent of `std::max_align_t`, and
`boost::core::max_align`, the alignment of `max_align_t`.
* Added [link core.memory_resource `boost::core::memory_resource`], a portable equivalent of `std::pmr::memory_resource`
from C++17.
* Added [link core.serialization `boost/core/serialization.hpp`], a collection of primitives allowing libraries to
implement Boost.Serialization support for their types without including a Serialization header and thereby making
their libraries depend on Serialization.
* Added [link core.data `boost::data`], an implementation of `std::data`.
* Added [link core.size `boost::size`], an implementation of `std::size`.
* Updated `boost::span` to use `boost::data` which adds support for range
construction from an `std::initializer_list`.
* Added [link core.identity `boost::identity`], an implementation of
`std::identity`. This facility has been moved from Boost.Functional.
[endsect]

View File

@@ -41,11 +41,13 @@ criteria for inclusion is that the utility component be:
[include changes.qbk]
[include addressof.qbk]
[include alignof.qbk]
[include allocator_access.qbk]
[include allocator_traits.qbk]
[include bit.qbk]
[include checked_delete.qbk]
[include cmath.qbk]
[include data.qbk]
[include default_allocator.qbk]
[include demangle.qbk]
[include empty_value.qbk]
@@ -53,9 +55,14 @@ criteria for inclusion is that the utility component be:
[include exchange.qbk]
[include explicit_operator_bool.qbk]
[include first_scalar.qbk]
[include identity.qbk]
[include ignore_unused.qbk]
[include is_same.qbk]
[include launder.qbk]
[include lightweight_test.qbk]
[include make_span.qbk]
[include max_align.qbk]
[include memory_resource.qbk]
[include no_exceptions_support.qbk]
[include noinit_adaptor.qbk]
[include noncopyable.qbk]
@@ -66,6 +73,8 @@ criteria for inclusion is that the utility component be:
[include quick_exit.qbk]
[include ref.qbk]
[include scoped_enum.qbk]
[include serialization.qbk]
[include size.qbk]
[include span.qbk]
[include swap.qbk]
[include typeinfo.qbk]

67
doc/data.qbk Normal file
View File

@@ -0,0 +1,67 @@
[/
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:data data]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/data.hpp> provides function templates `data`
to obtain the pointer to the first element in a range.
[endsect]
[section Reference]
```
namespace boost {
template<class C>
constexpr auto
data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data());
template<class C>
constexpr auto
data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data());
template<class T, std::size_t N>
constexpr T*
data(T(&a)[N]) noexcept;
template<class T>
constexpr const T*
data(std::initializer_list<T> l) noexcept;
} /* boost */
```
[section Functions]
[variablelist
[[`template<class C> constexpr auto data(C& c) noexcept(noexcept(c.data())) ->
decltype(c.data());`]
[Returns `c.data()`.]]
[[`template<class C> constexpr auto data(const C& c)
noexcept(noexcept(c.data())) -> decltype(c.data());`]
[Returns `c.data()`.]]
[[`template<class T, std::size_t N> constexpr T* data(T(&a)[N]) noexcept;`]
[Returns `a`.]]
[[`template<class T> constexpr const T* data(std::initializer_list<T> l)
noexcept;`]
[Returns `l.begin()`.]]]
[endsect]
[endsect]
[endsect]

61
doc/identity.qbk Normal file
View File

@@ -0,0 +1,61 @@
[/
Copyright 2021-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:identity identity]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/functional/identity.hpp> provides the function object
`boost::identity` whose `operator()` returns its argument. It is an
implementation of C++20's `std::identity` that supports C++03 and above.
[endsect]
[section Example]
It is commonly used as the default projection in constrained algorithms.
```
template<class Range, class Projection = boost::identity>
void print(Range&& range, Projection projection = {});
```
[endsect]
[section Reference]
```
namespace boost {
struct identity {
using is_transparent = unspecified;
template<class T>
T&& operator()(T&& value) const noexcept;
};
} /* boost */
```
[section Operators]
[variablelist
[[`template<class T> T&& operator()(T&& value) const noexcept;`]
[Returns `std::forward<T>(value)`.]]]
[endsect]
[endsect]
[endsect]

39
doc/launder.qbk Normal file
View File

@@ -0,0 +1,39 @@
[/
Copyright 2023 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:launder launder]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/launder.hpp>]
The header `<boost/core/launder.hpp>` defines the function
`void boost::core::launder()`, a portable implementation of
`std::launder`.
[section Synopsis]
``
namespace boost
{
namespace core
{
template<class T> T* launder( T* p );
} // namespace core
} // namespace boost
``
[endsect]
[endsect]
[endsect]

81
doc/make_span.qbk Normal file
View File

@@ -0,0 +1,81 @@
[/
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:make_span make_span]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/make_span.hpp> provides function templates `make_span`
to conveniently create `span` objects. They are useful before C++17 where Class
Template Argument Deduction (CTAD) is not available.
[endsect]
[section Reference]
```
namespace boost {
template<class I>
constexpr span<I>
make_span(I* d, std::size_t n) noexcept;
template<class I>
constexpr span<I>
make_span(I* b, I* e) noexcept;
template<class T, std::size_t N>
constexpr span<T, N>
make_span(T(&a)[N]) noexcept;
template<class T, std::size_t N>
constexpr span<T, N>
make_span(std::array<T, N>& a) noexcept;
template<class T, std::size_t N>
constexpr span<const T, N>
make_span(const std::array<T, N>& a) noexcept;
template<class R>
span<remove_pointer_t<iterator_t<R> > >
make_span(R&& r);
} /* boost */
```
[section Functions]
[variablelist
[[`template<class I> span<I> make_span(I* f, std::size_t c);`]
[Returns `span<I>(f, c)`.]]
[[`template<class I> span<I> make_span(I* f, I* l);`]
[Returns `span<I>(f, l)`.]]
[[`template<class T, std::size_t N> span<T, N> make_span(T(&a)[N]);`]
[Returns `span<T, N>(a)`.]]
[[`template<class T, std::size_t N> span<T, N>
make_span(std::array<T, N>& a);`]
[Returns `span<T, N>(a)`.]]
[[`template<class T, std::size_t N> span<const T, N>
make_span(const std::array<T, N>& a);`]
[Returns `span<const T, N>(a)`.]]
[[`template<class R>
span<remove_pointer_t<iterator_t<R> > >
make_span(R&& r);`]
[Returns `span<remove_pointer_t<iterator_t<R> > >(std::forward<R>(r))`.]]]
[endsect]
[endsect]
[endsect]

42
doc/max_align.qbk Normal file
View File

@@ -0,0 +1,42 @@
[/
Copyright 2023 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:max_align max_align]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/max_align.hpp>]
The header `<boost/core/max_align.hpp>` defines the type
`boost::core::max_align_t`, a portable equivalent of
`std::max_align_t`, and the constant `boost::core::max_align`,
the alignment of `max_align_t`.
[section Synopsis]
``
namespace boost
{
namespace core
{
union max_align_t;
constexpr std::size_t max_align = alignof(max_align_t);
} // namespace core
} // namespace boost
``
[endsect]
[endsect]
[endsect]

139
doc/memory_resource.qbk Normal file
View File

@@ -0,0 +1,139 @@
[/
Copyright 2023 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:memory_resource memory_resource]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/memory_resource.hpp>]
The header `<boost/core/memory_resource.hpp>` defines the class
`boost::core::memory_resource`, a portable equivalent of
`std::pmr::memory_resource` from C++17.
This is not a complete implementation of the standard `<memory_resource>`
header; for such, one should use Boost.Container. The abstract base class
is only provided by Core so that Boost libraries that provide and take
advantage of PMR facilities such as concrete implementations of memory
resources, or implementations of `polymorphic_allocator`, can interoperate.
[section Synopsis]
``
namespace boost
{
namespace core
{
class memory_resource
{
public:
virtual ~memory_resource() = default;
[[nodiscard]] void* allocate( std::size_t bytes, std::size_t alignment = max_align );
void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align );
bool is_equal( memory_resource const & other ) const noexcept;
private:
virtual void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;
virtual void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;
virtual bool do_is_equal( memory_resource const& other ) const noexcept = 0;
};
inline bool operator==( memory_resource const& a, memory_resource const& b ) noexcept;
inline bool operator!=( memory_resource const& a, memory_resource const& b ) noexcept;
} // namespace core
} // namespace boost
``
[endsect]
[section `allocate`]
`[[nodiscard]] void* allocate( std::size_t bytes, std::size_t alignment = max_align );`
* *Returns:* `do_allocate( bytes, alignment )`.
* *Remarks:* Implicitly creates objects in the returned region of storage.
[endsect]
[section `deallocate`]
`void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align );`
* *Effects:* `do_deallocate( bytes, alignment )`.
[endsect]
[section `is_equal`]
`bool is_equal( memory_resource const& other ) const noexcept;`
* *Returns:* `do_is_equal( other )`.
[endsect]
[section `do_allocate`]
`void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;`
* *Remarks:* A derived class should implement this member function to return
a pointer to allocated storage of size at least `bytes` and alignment at
least `alignment`.
* *Throws:* An appropriate exception (by convention `std::bad_alloc` or
derived) when storage with the specified size and alignment could not be
obtained.
[endsect]
[section `do_deallocate`]
`void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;`
* *Remarks:* A derived class should implement this member function to deallocate
a region of storage previously allocated by `do_allocate`.
* *Throws:* Nothing.
[endsect]
[section `do_is_equal`]
`bool do_is_equal( memory_resource const& other ) const noexcept = 0;`
* *Remarks:* A derived class shall implement this function to return `true` if
memory allocated from `*this` can be deallocated from `other` and vice-versa,
otherwise `false`.
[endsect]
[section `operator==`]
`bool operator==( memory_resource const& a, memory_resource const& b ) noexcept;`
* *Returns:* `&a == &b || a.is_equal( b )`.
[endsect]
[section `operator!=`]
`bool operator!=( memory_resource const& a, memory_resource const& b ) noexcept;`
* *Returns:* `!( a == b )`.
[endsect]
[endsect]
[endsect]

145
doc/serialization.qbk Normal file
View File

@@ -0,0 +1,145 @@
[/
Copyright 2023 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
https://boost.org/LICENSE_1_0.txt
]
[section:serialization serialization]
[simplesect Authors]
* Peter Dimov
[endsimplesect]
[section Header <boost/core/serialization.hpp>]
The header `<boost/core/serialization.hpp>` implements primitives
that are necessary to implement Boost.Serialization support without
including a Boost.Serialization header and thereby making a library
dependent on Boost.Serialization.
[section Synopsis]
``
#include <boost/core/nvp.hpp>
namespace boost
{
namespace serialization
{
// forward declarations
template<class T> struct version;
class access;
// core_version_type
struct core_version_type;
} // namespace serialization
namespace core
{
// nvp
using serialization::nvp;
using serialization::make_nvp;
// split_free
template<class Ar, class T> void split_free( Ar& ar, T& t, unsigned int v );
// split_member
template<class Ar, class T> void split_member( Ar& ar, T& t, unsigned int v );
// load_construct_data_adl
template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v );
// save_construct_data_adl
template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v );
} // namespace core
} // namespace boost
``
[endsect]
[section `core_version_type`]
``
struct core_version_type
{
unsigned int version_;
core_version_type( unsigned int version ): version_( version ) {}
operator unsigned int () const { return version_; }
};
``
`core_version_type` is a Core reimplementation of
`boost::serialization::version_type`, needed to call ADL serialization
primitives such as, for example, `load_construct_data` below.
It's defined in the `serialization` namespace instead of the `core`
namespace because its only purpose is to add `boost::serialization` to
the list of the associated namespaces of the corresponding call.
[endsect]
[section `split_free`]
`template<class Ar, class T> inline void split_free( Ar& ar, T& t, unsigned int v );`
`boost::core::split_free` is a Core reimplementation of
`boost::serialization::split_free`.
* *Effects:*
* If `Ar::is_saving::value` is `true`, calls `save( ar, t, core_version_type( v ) )`;
* Otherwise, calls `load( ar, t, core_version_type( v ) )`.
[endsect]
[section `split_member`]
`template<class Ar, class T> void split_member( Ar& ar, T& t, unsigned int v );`
`boost::core::split_member` is a Core reimplementation of
`boost::serialization::split_member`.
* *Effects:*
* If `Ar::is_saving::value` is `true`, calls `t.save( ar, v )`;
* Otherwise, calls `t.load( ar, v )`.
[endsect]
[section `load_construct_data_adl`]
`template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v );`
`boost::core::load_construct_data_adl` is a Core reimplementation of
`boost::serialization::load_construct_data_adl`.
* *Effects:* `load_construct_data( ar, t, serialization::core_version_type( v ) );`.
[endsect]
[section `save_construct_data_adl`]
`template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v );`
`boost::core::save_construct_data_adl` is a Core reimplementation of
`boost::serialization::save_construct_data_adl`.
* *Effects:* `save_construct_data( ar, t, serialization::core_version_type( v ) );`.
[endsect]
[endsect]
[endsect]

54
doc/size.qbk Normal file
View File

@@ -0,0 +1,54 @@
[/
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
]
[section:size size]
[simplesect Authors]
* Glen Fernandes
[endsimplesect]
[section Overview]
The header <boost/core/size.hpp> provides function templates `size` to obtain
the number of elements in a range.
[endsect]
[section Reference]
```
namespace boost {
template<class C>
constexpr auto
size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size());
template<class T, std::size_t N>
constexpr std::size_t
size(T(&)[N]) noexcept;
} /* boost */
```
[section Functions]
[variablelist
[[`template<class C> constexpr auto size(const C& c)
noexcept(noexcept(c.size())) -> decltype(c.size());`]
[Returns `c.size()`.]]
[[`template<class T, std::size_t N> constexpr std::size_t size(T(&)[N])
noexcept;`]
[Returns `N`.]]]
[endsect]
[endsect]
[endsect]

View File

@@ -149,7 +149,7 @@ template<class T, std::size_t N>
span(const std::array<T, N>&) -> span<const T, N>;
template<class R>
span(R&&) -> span<std::remove_pointer_t<decltype(std::declval<R&>().data())> >;
span(R&&) -> span<remove_pointer_t<iterator_t<R> > >;
template<class T, std::size_t E>
span<const std::byte, E == dynamic_extent ? dynamic_extent : sizeof(T) * E>
@@ -227,13 +227,13 @@ constexpr span(R&& r);`]
[`remove_cvref_t<R>` is not a specialization of `span`,]
[`remove_cvref_t<R>` is not a specialization of `array`,]
[`is_array_v<remove_cvref_t<R>>` is `false`,]
[`r.data()` is well-formed and
`is_convertible_v<remove_pointer_t<decltype(declval<R&>().data())>(*)[],
[`data(r)` is well-formed and
`is_convertible_v<remove_pointer_t<iterator_t<R> >(*)[],
T(*)[]>` is `true`, and]
[`r.size()` is well-formed and
`is_convertible_v<decltype(declval<R&>().size()), size_t>` is `true`.]]]]
[[Effects][Constructs a `span` with data `r.data()` and size `r.size()`.]]
[[Throws][What and when r.data() and r.size() throw.]]]]]
[[Effects][Constructs a `span` with data `data(r)` and size `r.size()`.]]
[[Throws][What and when data(r) and r.size() throw.]]]]]
[[`explicit(E != dynamic_extent && N == dynamic_extent)
template<class U, std::size_t N>
constexpr span(const span<U, N>& s) noexcept;`]

View File

@@ -22,7 +22,7 @@
[section Header <boost/core/swap.hpp>]
`template<class T> void swap(T& left, T& right);`
[^template<class T> void swap(T& left, T& right) noexcept(['see below]);]
[endsect]
@@ -40,13 +40,14 @@ specialized swap function is available, `std::swap` is used.
The generic `std::swap` function requires that the elements
to be swapped are assignable and copy constructible. It is
usually implemented using one copy construction and two
assignments - this is often both unnecessarily restrictive and
unnecessarily slow. In addition, where the generic swap
implementation provides only the basic guarantee, specialized
swap functions are often able to provide the no-throw exception
guarantee (and it is considered best practice to do so where
possible [footnote Scott Meyers, Effective C++ Third Edition,
Item 25: "Consider support for a non-throwing swap"].
assignments (C++11 replaces copy operations with move) - this
is often both unnecessarily restrictive and unnecessarily slow.
In addition, where the generic swap implementation provides
only the basic guarantee, specialized swap functions are often
able to provide the no-throw exception guarantee (and it is
considered best practice to do so where possible[footnote Scott
Meyers, Effective C++ Third Edition, Item 25: "Consider support
for a non-throwing swap"].
The alternative to using argument dependent lookup in this
situation is to provide a template specialization of
@@ -59,12 +60,12 @@ in their own namespaces.
`std::swap` originally did not do so, but a request to add an
overload of `std::swap` for built-in arrays has been accepted
by the C++ Standards Committee[footnote
[@http://open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#809
[@http://open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#809
LWG Defect Report 809: std::swap should be overloaded for array
types]].
[endsect]
[section Exception Safety]
`boost::swap` provides the same exception guarantee as the
@@ -73,30 +74,33 @@ of type `T[n]`, where `n > 1` and the underlying swap function
for `T` provides the strong exception guarantee, `boost::swap`
provides only the basic exception guarantee.
In C++11 and later, `boost::swap` propagates the same `noexcept`
specification as the one specified in the underlying swap function.
[endsect]
[section Requirements]
Either:
* T must be assignable
* T must be copy constructible
* `T` must be copy assignable (/since C++11:/ move assignable)
* `T` must be copy constructible (/since C++11:/ move constructible)
Or:
* A function with the signature `swap(T&,T&)` is available via
* A function with the signature `swap(T&, T&)` is available via
argument dependent lookup
Or:
* A template specialization of `std::swap` exists for T
* A template specialization of `std::swap` exists for `T`
Or:
* T is a built-in array of swappable elements
* `T` is a built-in array of swappable elements
[endsect]
[section Portability]
Several older compilers do not support argument dependent
@@ -104,11 +108,11 @@ lookup. On these compilers `boost::swap` will call
`std::swap`, ignoring any specialized swap functions that
could be found as a result of argument dependent lookup.
[endsect]
[endsect]
[section Credits]
* *Niels Dekker* - for implementing and documenting support for
* *Niels Dekker* - for implementing and documenting support for
built-in arrays
* *Joseph Gauterin* - for the initial idea, implementation,
tests, and documentation

8
extra/boost_core.natvis Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="boost::core::basic_string_view&lt;*&gt;">
<DisplayString>{p_,[n_]s}</DisplayString>
</Type>
</AutoVisualizer>

View File

@@ -0,0 +1,57 @@
#ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED
#define BOOST_CORE_ALIGNOF_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <cstddef>
#if !defined(BOOST_NO_CXX11_ALIGNOF)
#define BOOST_CORE_ALIGNOF alignof
#elif defined(__GNUC__)
#define BOOST_CORE_ALIGNOF __alignof__
#elif defined(_MSC_VER)
#define BOOST_CORE_ALIGNOF __alignof
#else
namespace boost
{
namespace core
{
namespace detail
{
template<class T> struct alignof_helper
{
char x;
T t;
};
} // namespace detail
} // namespace core
} // namespace boost
#if defined(__GNUC__)
// ignoring -Wvariadic-macros with #pragma doesn't work under GCC
# pragma GCC system_header
#endif
#define BOOST_CORE_ALIGNOF(...) offsetof( ::boost::core::detail::alignof_helper<__VA_ARGS__>, t );
#endif
#endif // #ifndef BOOST_CORE_ALIGNOF_HPP_INCLUDED

View File

@@ -0,0 +1,46 @@
/*
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_DATA_HPP
#define BOOST_CORE_DATA_HPP
#include <initializer_list>
#include <cstddef>
namespace boost {
template<class C>
inline constexpr auto
data(C& c) noexcept(noexcept(c.data())) -> decltype(c.data())
{
return c.data();
}
template<class C>
inline constexpr auto
data(const C& c) noexcept(noexcept(c.data())) -> decltype(c.data())
{
return c.data();
}
template<class T, std::size_t N>
inline constexpr T*
data(T(&a)[N]) noexcept
{
return a;
}
template<class T>
inline constexpr const T*
data(std::initializer_list<T> l) noexcept
{
return l.begin();
}
} /* boost */
#endif

View File

@@ -27,6 +27,27 @@ inline void lwt_unattended()
// disable message boxes on assert(), abort()
::_set_abort_behavior( 0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT );
# pragma warning(push)
# pragma warning(disable: 4996)
# if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
# endif
#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == 100 /*WINAPI_FAMILY_DESKTOP_APP*/
// disable message box on crash
::_seterrormode( /*SEM_NOGPFAULTERRORBOX*/ 0x0002 );
#endif
# if defined(__clang__)
# pragma clang diagnostic pop
# endif
# pragma warning(pop)
#endif
#if defined(_MSC_VER) && defined(_CPPLIB_VER) && defined(_DEBUG)

View File

@@ -0,0 +1,61 @@
/*
Copyright 2021-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_IDENTITY_HPP
#define BOOST_CORE_IDENTITY_HPP
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
#include <utility>
#endif
namespace boost {
struct identity {
typedef void is_transparent;
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
BOOST_CONSTEXPR T&& operator()(T&& value) const BOOST_NOEXCEPT {
return std::forward<T>(value);
}
#else
template<class T>
BOOST_CONSTEXPR const T& operator()(const T& value) const BOOST_NOEXCEPT {
return value;
}
template<class T>
BOOST_CONSTEXPR T& operator()(T& value) const BOOST_NOEXCEPT {
return value;
}
#endif
template<class>
struct result { };
template<class T>
struct result<identity(T&)> {
typedef T& type;
};
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
template<class T>
struct result<identity(T)> {
typedef T&& type;
};
template<class T>
struct result<identity(T&&)> {
typedef T&& type;
};
#endif
};
} /* boost */
#endif

View File

@@ -0,0 +1,55 @@
#ifndef BOOST_CORE_LAUNDER_HPP_INCLUDED
#define BOOST_CORE_LAUNDER_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__has_builtin)
# if __has_builtin(__builtin_launder)
# define BOOST_CORE_HAS_BUILTIN_LAUNDER
# endif
#endif
#if (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && !defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
# include <new>
#endif
namespace boost
{
namespace core
{
#if defined(BOOST_CORE_HAS_BUILTIN_LAUNDER)
template<class T> T* launder( T* p )
{
return __builtin_launder( p );
}
#elif (__cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && defined(__cpp_lib_launder)
template<class T> T* launder( T* p )
{
return std::launder( p );
}
#else
template<class T> T* launder( T* p )
{
return p;
}
#endif
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_LAUNDER_HPP_INCLUDED

View File

@@ -0,0 +1,59 @@
/*
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_MAKE_SPAN_HPP
#define BOOST_CORE_MAKE_SPAN_HPP
#include <boost/core/span.hpp>
namespace boost {
template<class I>
inline constexpr span<I>
make_span(I* f, std::size_t c) noexcept
{
return span<I>(f, c);
}
template<class I>
inline constexpr span<I>
make_span(I* f, I* l) noexcept
{
return span<I>(f, l);
}
template<class T, std::size_t N>
inline constexpr span<T, N>
make_span(T(&a)[N]) noexcept
{
return span<T, N>(a);
}
template<class T, std::size_t N>
inline constexpr span<T, N>
make_span(std::array<T, N>& a) noexcept
{
return span<T, N>(a);
}
template<class T, std::size_t N>
inline constexpr span<const T, N>
make_span(const std::array<T, N>& a) noexcept
{
return span<const T, N>(a);
}
template<class R>
inline span<typename detail::span_data<R>::type>
make_span(R&& r)
{
return span<typename detail::span_data<R>::type>(std::forward<R>(r));
}
} /* boost */
#endif

View File

@@ -0,0 +1,82 @@
#ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
#define BOOST_CORE_MAX_ALIGN_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/alignof.hpp>
#include <boost/config.hpp>
#include <cstddef>
// BOOST_CORE_HAS_FLOAT128
#if defined(BOOST_HAS_FLOAT128)
# define BOOST_CORE_HAS_FLOAT128
#elif defined(__SIZEOF_FLOAT128__)
# define BOOST_CORE_HAS_FLOAT128
#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) && defined(__i386__)
# define BOOST_CORE_HAS_FLOAT128
#endif
// max_align_t, max_align
namespace boost
{
namespace core
{
union max_align_t
{
char c;
short s;
int i;
long l;
#if !defined(BOOST_NO_LONG_LONG)
boost::long_long_type ll;
#endif
#if defined(BOOST_HAS_INT128)
boost::int128_type i128;
#endif
float f;
double d;
long double ld;
#if defined(BOOST_CORE_HAS_FLOAT128)
__float128 f128;
#endif
void* p;
void (*pf) ();
int max_align_t::* pm;
void (max_align_t::*pmf)();
};
BOOST_CONSTEXPR_OR_CONST std::size_t max_align = BOOST_CORE_ALIGNOF( max_align_t );
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_MAX_ALIGN_HPP_INCLUDED

View File

@@ -0,0 +1,108 @@
#ifndef BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED
#define BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/max_align.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef>
// Define our own placement new to avoid the inclusion of <new>
// (~9K extra lines) at Ion Gaztanhaga's request.
//
// We can use our own because [intro.object] p13 says:
//
// Any implicit or explicit invocation of a function named `operator new`
// or `operator new[]` implicitly creates objects in the returned region of
// storage and returns a pointer to a suitable created object.
namespace boost
{
namespace core
{
namespace detail
{
struct placement_new_tag {};
} // namespace detail
} // namespace core
} // namespace boost
inline void* operator new( std::size_t, void* p, boost::core::detail::placement_new_tag )
{
return p;
}
inline void operator delete( void*, void*, boost::core::detail::placement_new_tag )
{
}
namespace boost
{
namespace core
{
class memory_resource
{
public:
#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40700)
virtual ~memory_resource() {}
#else
virtual ~memory_resource() = default;
#endif
BOOST_ATTRIBUTE_NODISCARD void* allocate( std::size_t bytes, std::size_t alignment = max_align )
{
// https://github.com/boostorg/container/issues/199
// https://cplusplus.github.io/LWG/issue3471
return ::operator new( bytes, do_allocate( bytes, alignment ), core::detail::placement_new_tag() );
}
void deallocate( void* p, std::size_t bytes, std::size_t alignment = max_align )
{
do_deallocate( p, bytes, alignment );
}
bool is_equal( memory_resource const & other ) const BOOST_NOEXCEPT
{
return do_is_equal( other );
}
private:
virtual void* do_allocate( std::size_t bytes, std::size_t alignment ) = 0;
virtual void do_deallocate( void* p, std::size_t bytes, std::size_t alignment ) = 0;
virtual bool do_is_equal( memory_resource const & other ) const BOOST_NOEXCEPT = 0;
};
inline bool operator==( memory_resource const& a, memory_resource const& b ) BOOST_NOEXCEPT
{
return &a == &b || a.is_equal( b );
}
inline bool operator!=( memory_resource const& a, memory_resource const& b ) BOOST_NOEXCEPT
{
return !( a == b );
}
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_MEMORY_RESOURCE_HPP_INCLUDED

View File

@@ -1,17 +1,15 @@
#ifndef BOOST_CORE_REF_HPP
#define BOOST_CORE_REF_HPP
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp>
#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
//
// ref.hpp - ref/cref, useful helper functions
//
@@ -61,9 +59,11 @@ template< class Y, class T > struct ref_convertible
enum _vt { value = sizeof( (f)( static_cast<Y*>(0) ) ) == sizeof(yes) };
};
#if defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
struct ref_empty
{
};
#endif
} // namespace detail
@@ -92,11 +92,11 @@ public:
@remark Does not throw.
*/
BOOST_FORCEINLINE explicit reference_wrapper(T& t): t_(boost::addressof(t)) {}
BOOST_FORCEINLINE explicit reference_wrapper(T& t) BOOST_NOEXCEPT : t_(boost::addressof(t)) {}
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ): t_( boost::addressof( t ) ) {}
BOOST_FORCEINLINE explicit reference_wrapper( T & t, ref_workaround_tag ) BOOST_NOEXCEPT : t_( boost::addressof( t ) ) {}
#endif
@@ -117,30 +117,37 @@ public:
@remark Only enabled when `Y*` is convertible to `T*`.
@remark Does not throw.
*/
template<class Y> reference_wrapper( reference_wrapper<Y> r,
typename enable_if_c<boost::detail::ref_convertible<Y, T>::value,
boost::detail::ref_empty>::type = boost::detail::ref_empty() ): t_( r.t_ )
#if !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
template<class Y, class = typename enable_if_c<boost::detail::ref_convertible<Y, T>::value>::type>
reference_wrapper( reference_wrapper<Y> r ) BOOST_NOEXCEPT : t_( r.t_ )
{
}
#else
template<class Y> reference_wrapper( reference_wrapper<Y> r,
typename enable_if_c<boost::detail::ref_convertible<Y, T>::value,
boost::detail::ref_empty>::type = boost::detail::ref_empty() ) BOOST_NOEXCEPT : t_( r.t_ )
{
}
#endif
/**
@return The stored reference.
@remark Does not throw.
*/
BOOST_FORCEINLINE operator T& () const { return *t_; }
BOOST_FORCEINLINE operator T& () const BOOST_NOEXCEPT { return *t_; }
/**
@return The stored reference.
@remark Does not throw.
*/
BOOST_FORCEINLINE T& get() const { return *t_; }
BOOST_FORCEINLINE T& get() const BOOST_NOEXCEPT { return *t_; }
/**
@return A pointer to the object referenced by the stored
reference.
@remark Does not throw.
*/
BOOST_FORCEINLINE T* get_pointer() const { return t_; }
BOOST_FORCEINLINE T* get_pointer() const BOOST_NOEXCEPT { return t_; }
private:
@@ -165,7 +172,7 @@ private:
@return `reference_wrapper<T>(t)`
@remark Does not throw.
*/
template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T & t )
template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T & t ) BOOST_NOEXCEPT
{
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1600 )
@@ -184,7 +191,7 @@ template<class T> BOOST_FORCEINLINE reference_wrapper<T> BOOST_REF_CONST ref( T
@return `reference_wrapper<T const>(t)`
@remark Does not throw.
*/
template<class T> BOOST_FORCEINLINE reference_wrapper<T const> BOOST_REF_CONST cref( T const & t )
template<class T> BOOST_FORCEINLINE reference_wrapper<T const> BOOST_REF_CONST cref( T const & t ) BOOST_NOEXCEPT
{
return reference_wrapper<T const>(t);
}
@@ -315,7 +322,7 @@ template<typename T> struct unwrap_reference< reference_wrapper<T> const volatil
@return `unwrap_reference<T>::type&(t)`
@remark Does not throw.
*/
template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_ref( T & t )
template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_ref( T & t ) BOOST_NOEXCEPT
{
return t;
}
@@ -325,7 +332,7 @@ template<class T> BOOST_FORCEINLINE typename unwrap_reference<T>::type& unwrap_r
/**
@cond
*/
template<class T> BOOST_FORCEINLINE T* get_pointer( reference_wrapper<T> const & r )
template<class T> BOOST_FORCEINLINE T* get_pointer( reference_wrapper<T> const & r ) BOOST_NOEXCEPT
{
return r.get_pointer();
}

View File

@@ -0,0 +1,131 @@
#ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED
#define BOOST_CORE_SERIALIZATION_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
//
// Utilities needed to implement serialization support
// without including a Boost.Serialization header
#include <boost/core/nvp.hpp>
#include <cstddef>
namespace boost
{
namespace serialization
{
// Forward declarations (needed for specializations)
template<class T> struct version;
class access;
// Our own version_type replacement. This has to be in
// the `serialization` namespace, because its only purpose
// is to add `serialization` as an associated namespace.
struct core_version_type
{
unsigned int version_;
core_version_type( unsigned int version ): version_( version ) {}
operator unsigned int () const { return version_; }
};
} // namespace serialization
namespace core
{
// nvp
using serialization::nvp;
using serialization::make_nvp;
// split_free
namespace detail
{
template<bool IsSaving> struct load_or_save_f;
template<> struct load_or_save_f<true>
{
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
{
save( a, t, serialization::core_version_type( v ) );
}
};
template<> struct load_or_save_f<false>
{
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
{
load( a, t, serialization::core_version_type( v ) );
}
};
} // namespace detail
template<class A, class T> inline void split_free( A& a, T& t, unsigned int v )
{
detail::load_or_save_f< A::is_saving::value >()( a, t, v );
}
// split_member
namespace detail
{
template<bool IsSaving, class Access = serialization::access> struct load_or_save_m;
template<class Access> struct load_or_save_m<true, Access>
{
template<class A, class T> void operator()( A& a, T const& t, unsigned int v ) const
{
Access::member_save( a, t, v );
}
};
template<class Access> struct load_or_save_m<false, Access>
{
template<class A, class T> void operator()( A& a, T& t, unsigned int v ) const
{
Access::member_load( a, t, v );
}
};
} // namespace detail
template<class A, class T> inline void split_member( A& a, T& t, unsigned int v )
{
detail::load_or_save_m< A::is_saving::value >()( a, t, v );
}
// load_construct_data_adl
template<class Ar, class T> void load_construct_data_adl( Ar& ar, T* t, unsigned int v )
{
load_construct_data( ar, t, serialization::core_version_type( v ) );
}
// save_construct_data_adl
template<class Ar, class T> void save_construct_data_adl( Ar& ar, T const* t, unsigned int v )
{
save_construct_data( ar, t, serialization::core_version_type( v ) );
}
} // namespace core
} // namespace boost
#endif // #ifndef BOOST_CORE_SERIALIZATION_HPP_INCLUDED

View File

@@ -0,0 +1,31 @@
/*
Copyright 2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CORE_SIZE_HPP
#define BOOST_CORE_SIZE_HPP
#include <cstddef>
namespace boost {
template<class C>
inline constexpr auto
size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size())
{
return c.size();
}
template<class T, std::size_t N>
inline constexpr std::size_t
size(T(&)[N]) noexcept
{
return N;
}
} /* boost */
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019 Glen Joseph Fernandes
Copyright 2019-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@@ -8,10 +8,10 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_CORE_SPAN_HPP
#define BOOST_CORE_SPAN_HPP
#include <boost/core/data.hpp>
#include <array>
#include <iterator>
#include <type_traits>
#include <cstddef>
namespace boost {
@@ -39,10 +39,8 @@ struct span_compatible {
};
template<class T>
struct span_uncvref {
typedef typename std::remove_cv<typename
std::remove_reference<T>::type>::type type;
};
using span_uncvref = typename std::remove_cv<typename
std::remove_reference<T>::type>::type;
template<class>
struct span_is_span {
@@ -64,15 +62,16 @@ struct span_is_array<std::array<T, N> > {
static constexpr bool value = true;
};
template<class T>
using span_ptr = decltype(boost::data(std::declval<T&>()));
template<class, class = void>
struct span_data { };
template<class T>
struct span_data<T,
typename std::enable_if<std::is_pointer<decltype(std::declval<T
&>().data())>::value>::type> {
typedef typename std::remove_pointer<decltype(std::declval<T
&>().data())>::type type;
typename std::enable_if<std::is_pointer<span_ptr<T> >::value>::type> {
typedef typename std::remove_pointer<span_ptr<T> >::type type;
};
template<class, class, class = void>
@@ -102,9 +101,9 @@ template<class R, class T>
struct span_is_range {
static constexpr bool value = (std::is_const<T>::value ||
std::is_lvalue_reference<R>::value) &&
!span_is_span<typename span_uncvref<R>::type>::value &&
!span_is_array<typename span_uncvref<R>::type>::value &&
!std::is_array<typename span_uncvref<R>::type>::value &&
!span_is_span<span_uncvref<R> >::value &&
!span_is_array<span_uncvref<R> >::value &&
!std::is_array<span_uncvref<R> >::value &&
span_has_data<R, T>::value &&
span_has_size<R>::value;
};
@@ -224,15 +223,16 @@ public:
template<class R,
typename std::enable_if<E == dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
constexpr span(R&& r) noexcept(noexcept(r.data()) && noexcept(r.size()))
: s_(r.data(), r.size()) { }
constexpr span(R&& r) noexcept(noexcept(boost::data(r)) &&
noexcept(r.size()))
: s_(boost::data(r), r.size()) { }
template<class R,
typename std::enable_if<E != dynamic_extent &&
detail::span_is_range<R, T>::value, int>::type = 0>
explicit constexpr span(R&& r) noexcept(noexcept(r.data()) &&
explicit constexpr span(R&& r) noexcept(noexcept(boost::data(r)) &&
noexcept(r.size()))
: s_(r.data(), r.size()) { }
: s_(boost::data(r), r.size()) { }
template<class U, std::size_t N,
typename std::enable_if<detail::span_implicit<E, N>::value &&

View File

@@ -13,10 +13,10 @@
// - swap_impl is put outside the boost namespace, to avoid infinite
// recursion (causing stack overflow) when swapping objects of a primitive
// type.
// - swap_impl has a using-directive, rather than a using-declaration,
// because some compilers (including MSVC 7.1, Borland 5.9.3, and
// Intel 8.1) don't do argument-dependent lookup when it has a
// using-declaration instead.
// - std::swap is imported with a using-directive, rather than
// a using-declaration, because some compilers (including MSVC 7.1,
// Borland 5.9.3, and Intel 8.1) don't do argument-dependent lookup
// when it has a using-declaration instead.
// - boost::swap has two template arguments, instead of one, to
// avoid ambiguity when swapping objects of a Boost type that does
// not have its own boost::swap overload.
@@ -30,6 +30,17 @@
#endif
#include <cstddef> // for std::size_t
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
#endif
#if defined(BOOST_GCC) && (BOOST_GCC < 40700)
// gcc 4.6 ICEs on noexcept specifications below
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x)
#else
#define BOOST_CORE_SWAP_NOEXCEPT_IF(x) BOOST_NOEXCEPT_IF(x)
#endif
namespace boost_swap_impl
{
// we can't use type_traits here
@@ -37,17 +48,22 @@ namespace boost_swap_impl
template<class T> struct is_const { enum _vt { value = 0 }; };
template<class T> struct is_const<T const> { enum _vt { value = 1 }; };
// Use std::swap if argument dependent lookup fails.
// We need to have this at namespace scope to be able to use unqualified swap() call
// in noexcept specification.
using namespace std;
template<class T>
BOOST_GPU_ENABLED
void swap_impl(T& left, T& right)
void swap_impl(T& left, T& right) BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(swap(left, right)))
{
using namespace std;//use std::swap if argument dependent lookup fails
swap(left,right);
swap(left, right);
}
template<class T, std::size_t N>
BOOST_GPU_ENABLED
void swap_impl(T (& left)[N], T (& right)[N])
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::swap_impl(left[0], right[0])))
{
for (std::size_t i = 0; i < N; ++i)
{
@@ -62,9 +78,12 @@ namespace boost
BOOST_GPU_ENABLED
typename enable_if_c< !boost_swap_impl::is_const<T1>::value && !boost_swap_impl::is_const<T2>::value >::type
swap(T1& left, T2& right)
BOOST_CORE_SWAP_NOEXCEPT_IF(BOOST_NOEXCEPT_EXPR(::boost_swap_impl::swap_impl(left, right)))
{
::boost_swap_impl::swap_impl(left, right);
}
}
#endif
#undef BOOST_CORE_SWAP_NOEXCEPT_IF
#endif // BOOST_CORE_SWAP_HPP

View File

@@ -31,6 +31,13 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::config Boost::move Boost::smart
boost_test(TYPE run SOURCES fclose_deleter_test.cpp)
set(BOOST_TEST_LINK_LIBRARIES Boost::core Boost::serialization)
boost_test(TYPE run SOURCES serialization_nvp_test.cpp)
boost_test(TYPE run SOURCES serialization_split_free_test.cpp)
boost_test(TYPE run SOURCES serialization_split_member_test.cpp)
boost_test(TYPE run SOURCES serialization_construct_data_test.cpp)
endif()
add_subdirectory(swap)

View File

@@ -343,6 +343,7 @@ run span_deduction_guide_test.cpp ;
run as_bytes_test.cpp ;
run as_writable_bytes_test.cpp ;
compile span_boost_begin_test.cpp ;
run make_span_test.cpp ;
run splitmix64_test.cpp
: : : $(pedantic-errors) ;
@@ -352,5 +353,23 @@ run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off : verb
run-fail verbose_terminate_handler_fail.cpp : : : <rtti>off : verbose_terminate_handler_fail_nr ;
run-fail verbose_terminate_handler_fail.cpp : : : <exception-handling>off <rtti>off : verbose_terminate_handler_fail_nxr ;
run launder_test.cpp ;
run alignof_test.cpp ;
run max_align_test.cpp ;
run memory_resource_test.cpp ;
run data_test.cpp ;
run size_test.cpp ;
run serialization_nvp_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<build>no ;
run serialization_split_free_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
run serialization_split_member_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
run serialization_construct_data_test.cpp : : : <library>/boost//serialization/<warnings>off <undefined-sanitizer>norecover:<link>static ;
run identity_test.cpp ;
run identity_rvalue_test.cpp ;
use-project /boost/core/swap : ./swap ;
build-project ./swap ;

98
test/alignof_test.cpp Normal file
View File

@@ -0,0 +1,98 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/alignof.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits.hpp>
#include <boost/config.hpp>
#include <cstddef>
template<class T> struct struct_of
{
T t;
};
template<class T> union union_of
{
T t;
};
template<class T> void test2()
{
BOOST_TEST_EQ( BOOST_CORE_ALIGNOF(T), boost::alignment_of<T>::value );
#if !defined(BOOST_NO_CXX11_ALIGNOF)
BOOST_TEST_EQ( BOOST_CORE_ALIGNOF(T), alignof(T) );
#endif
}
template<class T> void test()
{
test2<T>();
test2<T[2]>();
test2< struct_of<T> >();
test2< union_of<T> >();
}
struct X
{
};
int main()
{
test<char>();
test<short>();
test<int>();
test<long>();
#if !defined(BOOST_NO_LONG_LONG)
# if !( defined(__GNUC__) && defined(__i386__) )
// g++ -m32 has alignof(long long) = 8, but boost::alignment_of<long long>::value = 4
test<boost::long_long_type>();
# endif
#endif
#if defined(BOOST_HAS_INT128)
test<boost::int128_type>();
#endif
test<float>();
#if !( defined(__GNUC__) && defined(__i386__) )
// g++ -m32 has alignof(double) = 8, but boost::alignment_of<double>::value = 4
test<double>();
#endif
test<long double>();
#if defined(BOOST_HAS_FLOAT128)
test<__float128>();
#endif
test<void*>();
test<void(*)()>();
#if !defined(_MSC_VER)
// under MSVC, alignof is 8, boost::alignment_of is 4
// under clang-cl, alignof is 4, boost::alignment_of is 8 (!)
test<int X::*>();
#endif
test<void (X::*)()>();
return boost::report_errors();
}

View File

@@ -72,6 +72,7 @@ int main()
BOOST_TEST_EQ(p->value(), 2);
boost::alloc_destroy(a, p);
BOOST_TEST_EQ(type::count, 0);
a.deallocate(p, 1);
return boost::report_errors();
}
#else

68
test/data_test.cpp Normal file
View File

@@ -0,0 +1,68 @@
/*
Copyright 2023 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) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/data.hpp>
#include <boost/core/lightweight_test.hpp>
class range {
public:
int* data() {
return &v_[0];
}
const int* data() const {
return &v_[0];
}
std::size_t size() const {
return 4;
}
private:
int v_[4];
};
void test_range()
{
range c;
BOOST_TEST_EQ(boost::data(c), c.data());
}
void test_const_range()
{
const range c = range();
BOOST_TEST_EQ(boost::data(c), c.data());
}
void test_array()
{
int a[4];
BOOST_TEST_EQ(boost::data(a), a);
}
void test_initializer_list()
{
std::initializer_list<int> l{1, 2, 3, 4};
BOOST_TEST_EQ(boost::data(l), l.begin());
}
int main()
{
test_range();
test_const_range();
test_array();
test_initializer_list();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,69 @@
/*
Copyright 2021-2023 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_RVALUE_REFERENCES)
#include <boost/core/identity.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
bool test(std::string&&)
{
return true;
}
bool test(const std::string&&)
{
return true;
}
template<class T>
bool test(T&&)
{
return false;
}
void simple_test()
{
typedef std::string string;
BOOST_TEST(boost::identity()(string("a")) == string("a"));
BOOST_TEST(test(boost::identity()(string("a"))));
typedef const std::string cstring;
BOOST_TEST(boost::identity()(cstring("a")) == cstring("a"));
BOOST_TEST(test(boost::identity()(cstring("a"))));
}
void algorithm_test()
{
std::vector<std::string> v1;
v1.push_back(std::string("a"));
v1.push_back(std::string("b"));
v1.push_back(std::string("c"));
std::vector<std::string> v2(v1);
std::vector<std::string> v3;
std::transform(std::make_move_iterator(v2.begin()),
std::make_move_iterator(v2.end()),
std::back_inserter(v3),
boost::identity());
BOOST_TEST(v3 == v1);
}
int main()
{
simple_test();
algorithm_test();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

66
test/identity_test.cpp Normal file
View File

@@ -0,0 +1,66 @@
/*
Copyright 2021-2023 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/core/identity.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
bool test(std::string&)
{
return true;
}
bool test(const std::string&)
{
return true;
}
template<class T>
bool test(T&)
{
return false;
}
template<class T>
bool test(const T&)
{
return false;
}
void simple_test()
{
std::string s1("a");
BOOST_TEST(boost::identity()(s1) == s1);
BOOST_TEST(&boost::identity()(s1) == &s1);
BOOST_TEST(test(boost::identity()(s1)));
const std::string s2("a");
BOOST_TEST(boost::identity()(s2) == s2);
BOOST_TEST(&boost::identity()(s2) == &s2);
BOOST_TEST(test(boost::identity()(s2)));
}
void algorithm_test()
{
std::vector<std::string> v1;
v1.push_back(std::string("a"));
v1.push_back(std::string("b"));
v1.push_back(std::string("c"));
std::vector<std::string> v2;
std::transform(v1.begin(), v1.end(), std::back_inserter(v2),
boost::identity());
BOOST_TEST(v2 == v1);
}
int main()
{
simple_test();
algorithm_test();
return boost::report_errors();
}

34
test/launder_test.cpp Normal file
View File

@@ -0,0 +1,34 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/launder.hpp>
#include <boost/core/lightweight_test.hpp>
#include <new>
struct X
{
int v_;
explicit X( int v = 0 ): v_( v ) {}
};
int main()
{
X x;
typedef X const CX;
::new( &x ) CX( 1 );
X const* px1 = &x;
BOOST_TEST_EQ( px1->v_, 1 );
::new( &x ) CX( 2 );
X const* px2 = boost::core::launder( px1 );
BOOST_TEST_EQ( px1, px2 );
BOOST_TEST_EQ( px2->v_, 2 );
return boost::report_errors();
}

100
test/make_span_test.cpp Normal file
View File

@@ -0,0 +1,100 @@
/*
Copyright 2023 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) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/make_span.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T>
class range {
public:
T* data() {
return &v_[0];
}
std::size_t size() const {
return 4;
}
private:
T v_[4];
};
void test_data_size()
{
int a[4];
boost::span<int> s = boost::make_span(&a[0], 4);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_first_last()
{
int a[4];
boost::span<int> s = boost::make_span(&a[0], &a[4]);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_array()
{
int a[4];
boost::span<int, 4> s = boost::make_span(a);
BOOST_TEST_EQ(s.data(), &a[0]);
BOOST_TEST_EQ(s.size(), 4);
}
void test_std_array()
{
std::array<int, 4> a;
boost::span<int, 4> s = boost::make_span(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_const_std_array()
{
const std::array<int, 4> a = std::array<int, 4>();
boost::span<const int> s = boost::make_span(a);
BOOST_TEST_EQ(s.data(), a.data());
BOOST_TEST_EQ(s.size(), a.size());
}
void test_range()
{
range<int> c;
boost::span<int> s = boost::make_span(c);
BOOST_TEST_EQ(s.data(), c.data());
BOOST_TEST_EQ(s.size(), c.size());
}
void test_initializer_list()
{
std::initializer_list<int> l{1, 2};
boost::span<const int> s = boost::make_span(l);
BOOST_TEST_EQ(s.data(), l.begin());
BOOST_TEST_EQ(s.size(), l.size());
}
int main()
{
test_data_size();
test_first_last();
test_array();
test_std_array();
test_const_std_array();
test_range();
test_initializer_list();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

63
test/max_align_test.cpp Normal file
View File

@@ -0,0 +1,63 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/max_align.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits.hpp>
#include <boost/config.hpp>
#include <cstddef>
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 40900
# define BOOST_NO_STD_MAX_ALIGN_T
#endif
struct X
{
};
int main()
{
BOOST_TEST_EQ( boost::core::max_align, boost::alignment_of<boost::core::max_align_t>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<char>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<short>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<int>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<long>::value );
#if !defined(BOOST_NO_LONG_LONG)
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<boost::long_long_type>::value );
#endif
#if defined(BOOST_HAS_INT128)
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<boost::int128_type>::value );
#endif
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<float>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<double>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<long double>::value );
#if defined(BOOST_CORE_HAS_FLOAT128)
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<__float128>::value );
#endif
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void*>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void(*)()>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<int X::*>::value );
BOOST_TEST_GE( boost::core::max_align, boost::alignment_of<void (X::*)()>::value );
#if !defined(BOOST_NO_CXX11_ALIGNOF) && !defined(BOOST_NO_STD_MAX_ALIGN_T)
BOOST_TEST_GE( boost::core::max_align, alignof( std::max_align_t ) );
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,141 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/memory_resource.hpp>
#include <boost/core/lightweight_test.hpp>
#include <new>
#include <cstddef>
static bool do_allocate_called;
static std::size_t do_allocate_bytes;
static std::size_t do_allocate_alignment;
static bool do_deallocate_called;
static void* do_deallocate_p;
static std::size_t do_deallocate_bytes;
static std::size_t do_deallocate_alignment;
struct R1: public boost::core::memory_resource
{
void* do_allocate( std::size_t bytes, std::size_t alignment )
{
do_allocate_called = true;
do_allocate_bytes = bytes;
do_allocate_alignment = alignment;
return ::operator new( bytes );
}
void do_deallocate( void* p, std::size_t bytes, std::size_t alignment )
{
do_deallocate_called = true;
do_deallocate_p = p;
do_deallocate_bytes = bytes;
do_deallocate_alignment = alignment;
::operator delete( p );
}
bool do_is_equal( memory_resource const & /*other*/ ) const BOOST_NOEXCEPT
{
return true;
}
};
struct R2: public boost::core::memory_resource
{
void* do_allocate( std::size_t bytes, std::size_t /*alignment*/ )
{
return ::operator new( bytes );
}
void do_deallocate( void* p, std::size_t /*bytes*/, std::size_t /*alignment*/ )
{
::operator delete( p );
}
bool do_is_equal( memory_resource const & other ) const BOOST_NOEXCEPT
{
return this == &other;
}
};
int main()
{
{
R1 r1;
do_allocate_called = false;
do_allocate_bytes = 0;
do_allocate_alignment = 0;
void* p = r1.allocate( 31 );
BOOST_TEST( do_allocate_called );
BOOST_TEST_EQ( do_allocate_bytes, 31 );
BOOST_TEST_EQ( do_allocate_alignment, boost::core::max_align );
do_deallocate_called = false;
do_deallocate_p = 0;
do_deallocate_bytes = 0;
do_deallocate_alignment = 0;
r1.deallocate( p, 31 );
BOOST_TEST( do_deallocate_called );
BOOST_TEST_EQ( do_deallocate_p, p );
BOOST_TEST_EQ( do_deallocate_bytes, 31 );
BOOST_TEST_EQ( do_deallocate_alignment, boost::core::max_align );
}
{
R1 r1;
do_allocate_called = false;
do_allocate_bytes = 0;
do_allocate_alignment = 0;
void* p = r1.allocate( 1, 8 );
BOOST_TEST( do_allocate_called );
BOOST_TEST_EQ( do_allocate_bytes, 1 );
BOOST_TEST_EQ( do_allocate_alignment, 8 );
do_deallocate_called = false;
do_deallocate_p = 0;
do_deallocate_bytes = 0;
do_deallocate_alignment = 0;
r1.deallocate( p, 1, 8 );
BOOST_TEST( do_deallocate_called );
BOOST_TEST_EQ( do_deallocate_p, p );
BOOST_TEST_EQ( do_deallocate_bytes, 1 );
BOOST_TEST_EQ( do_deallocate_alignment, 8 );
}
{
R1 r1;
R1 r2;
BOOST_TEST( r1 == r1 );
BOOST_TEST_NOT( r1 != r1 );
BOOST_TEST( r1 == r2 );
BOOST_TEST_NOT( r1 != r2 );
}
{
R2 r1;
R2 r2;
BOOST_TEST( r1 == r1 );
BOOST_TEST_NOT( r1 != r1 );
BOOST_TEST_NOT( r1 == r2 );
BOOST_TEST( r1 != r2 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,102 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-copy" )
# pragma clang diagnostic ignored "-Wdeprecated-copy"
# endif
#endif
#include <boost/core/serialization.hpp>
#include <new>
struct X
{
int v_;
explicit X( int v ): v_( v ) {}
template<class Ar> void serialize( Ar& /*ar*/, unsigned /*v*/ )
{
}
};
template<class Ar> void save_construct_data( Ar& ar, X const* t, unsigned /*v*/ )
{
ar << t->v_;
}
template<class Ar> void load_construct_data( Ar& ar, X* t, unsigned /*v*/ )
{
int v;
ar >> v;
::new( t ) X( v );
}
struct Y
{
X x1, x2;
explicit Y( int v1, int v2 ): x1( v1 ), x2( v2 ) {}
private:
friend class boost::serialization::access;
template<class Ar> void load( Ar& ar, unsigned v )
{
boost::core::load_construct_data_adl( ar, &x1, v );
ar >> x1;
boost::core::load_construct_data_adl( ar, &x2, v );
ar >> x2;
}
template<class Ar> void save( Ar& ar, unsigned v ) const
{
boost::core::save_construct_data_adl( ar, &x1, v );
ar << x1;
boost::core::save_construct_data_adl( ar, &x2, v );
ar << x2;
}
template<class Ar> void serialize( Ar& ar, unsigned v )
{
boost::core::split_member( ar, *this, v );
}
};
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
int main()
{
std::ostringstream os;
Y y1( 7, 11 );
{
boost::archive::text_oarchive ar( os );
ar << y1;
}
std::string s = os.str();
Y y2( 0, 0 );
{
std::istringstream is( s );
boost::archive::text_iarchive ar( is );
ar >> y2;
}
BOOST_TEST_EQ( y1.x1.v_, y2.x1.v_ );
BOOST_TEST_EQ( y1.x2.v_, y2.x2.v_ );
return boost::report_errors();
}

View File

@@ -0,0 +1,55 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-copy" )
# pragma clang diagnostic ignored "-Wdeprecated-copy"
# endif
#endif
#include <boost/core/serialization.hpp>
struct X
{
int a, b;
template<class Ar> void serialize( Ar& ar, unsigned /*v*/ )
{
ar & boost::core::make_nvp( "a", a );
ar & boost::core::make_nvp( "b", b );
}
};
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
int main()
{
std::ostringstream os;
X x1 = { 7, 11 };
{
boost::archive::xml_oarchive ar( os );
ar << boost::core::make_nvp( "x1", x1 );
}
std::string s = os.str();
X x2 = { 0, 0 };
{
std::istringstream is( s );
boost::archive::xml_iarchive ar( is );
ar >> boost::make_nvp( "x2", x2 );
}
BOOST_TEST_EQ( x1.a, x2.a );
BOOST_TEST_EQ( x1.b, x2.b );
return boost::report_errors();
}

View File

@@ -0,0 +1,66 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-copy" )
# pragma clang diagnostic ignored "-Wdeprecated-copy"
# endif
#endif
#include <boost/core/serialization.hpp>
struct X
{
int a, b;
};
template<class Ar> void load( Ar& ar, X& x, unsigned /*v*/ )
{
ar >> x.a;
ar >> x.b;
}
template<class Ar> void save( Ar& ar, X const& x, unsigned /*v*/ )
{
ar << x.a;
ar << x.b;
}
template<class Ar> void serialize( Ar& ar, X& x, unsigned v )
{
boost::core::split_free( ar, x, v );
}
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
int main()
{
std::ostringstream os;
X x1 = { 7, 11 };
{
boost::archive::text_oarchive ar( os );
ar << x1;
}
std::string s = os.str();
X x2 = { 0, 0 };
{
std::istringstream is( s );
boost::archive::text_iarchive ar( is );
ar >> x2;
}
BOOST_TEST_EQ( x1.a, x2.a );
BOOST_TEST_EQ( x1.b, x2.b );
return boost::report_errors();
}

View File

@@ -0,0 +1,70 @@
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if defined(__clang__) && defined(__has_warning)
# if __has_warning( "-Wdeprecated-copy" )
# pragma clang diagnostic ignored "-Wdeprecated-copy"
# endif
#endif
#include <boost/core/serialization.hpp>
struct X
{
int a, b;
private:
friend class boost::serialization::access;
template<class Ar> void load( Ar& ar, unsigned /*v*/ )
{
ar >> a;
ar >> b;
}
template<class Ar> void save( Ar& ar, unsigned /*v*/ ) const
{
ar << a;
ar << b;
}
template<class Ar> void serialize( Ar& ar, unsigned v )
{
boost::core::split_member( ar, *this, v );
}
};
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/core/lightweight_test.hpp>
#include <sstream>
#include <string>
int main()
{
std::ostringstream os;
X x1 = { 7, 11 };
{
boost::archive::text_oarchive ar( os );
ar << x1;
}
std::string s = os.str();
X x2 = { 0, 0 };
{
std::istringstream is( s );
boost::archive::text_iarchive ar( is );
ar >> x2;
}
BOOST_TEST_EQ( x1.a, x2.a );
BOOST_TEST_EQ( x1.b, x2.b );
return boost::report_errors();
}

42
test/size_test.cpp Normal file
View File

@@ -0,0 +1,42 @@
/*
Copyright 2023 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) && !defined(BOOST_NO_CXX11_DECLTYPE)
#include <boost/core/size.hpp>
#include <boost/core/lightweight_test.hpp>
struct range {
std::size_t size() const {
return 4;
}
};
void test_range()
{
range c;
BOOST_TEST_EQ(boost::size(c), 4);
}
void test_array()
{
int a[4];
BOOST_TEST_EQ(boost::size(a), 4);
}
int main()
{
test_range();
test_array();
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019 Glen Joseph Fernandes
Copyright 2019-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@@ -140,6 +140,14 @@ void test_range()
range<derived>&>));
}
void test_initializer_list()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
std::initializer_list<int> >));
BOOST_TEST_TRAIT_FALSE((std::is_constructible<boost::span<int>,
std::initializer_list<int> >));
}
void test_span()
{
BOOST_TEST_TRAIT_TRUE((std::is_constructible<boost::span<const int>,
@@ -187,6 +195,7 @@ int main()
test_std_array();
test_const_std_array();
test_range();
test_initializer_list();
test_span();
test_copy();
test_assign();

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019 Glen Joseph Fernandes
Copyright 2019-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@@ -78,6 +78,15 @@ void test_range()
BOOST_TEST_EQ(s.size(), c.size());
}
void test_initializer_list()
{
std::initializer_list<int> l{1, 2};
boost::span s(l);
BOOST_TEST_EQ(s.extent, boost::dynamic_extent);
BOOST_TEST_EQ(s.data(), l.begin());
BOOST_TEST_EQ(s.size(), l.size());
}
void test_span_dynamic()
{
int a[4];
@@ -104,6 +113,7 @@ int main()
test_std_array();
test_const_std_array();
test_range();
test_initializer_list();
test_span_dynamic();
test_span_static();
return boost::report_errors();

View File

@@ -1,5 +1,5 @@
/*
Copyright 2019 Glen Joseph Fernandes
Copyright 2019-2023 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
@@ -118,6 +118,14 @@ void test_construct_range()
BOOST_TEST_EQ(s.size(), c.size());
}
void test_construct_initializer_list()
{
std::initializer_list<int> l{1, 2};
boost::span<const int> s(l);
BOOST_TEST_EQ(s.data(), l.begin());
BOOST_TEST_EQ(s.size(), l.size());
}
void test_construct_span_dynamic()
{
int a[4];
@@ -376,6 +384,7 @@ int main()
test_construct_const_std_array_dynamic();
test_construct_const_std_array_static();
test_construct_range();
test_construct_initializer_list();
test_construct_span_dynamic();
test_construct_span_dynamic_static();
test_construct_span_static();

View File

@@ -13,6 +13,7 @@ compile swap_lib_header_1.cpp ;
compile swap_lib_header_2.cpp ;
compile swap_mixed_headers_1.cpp ;
compile swap_mixed_headers_2.cpp ;
compile swap_noexcept.cpp ;
compile-fail swap_const_wrapper_fail.cpp ;

View File

@@ -46,13 +46,13 @@ int main()
const std::size_t array_size = 2;
const swap_test_class initial_array1[array_size] = { swap_test_class(1), swap_test_class(2) };
const swap_test_class initial_array2[array_size] = { swap_test_class(3), swap_test_class(4) };
swap_test_class array1[array_size];
swap_test_class array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);

View File

@@ -20,13 +20,13 @@ int main()
const std::size_t array_size = 3;
const int initial_array1[array_size] = { 1, 2, 3 };
const int initial_array2[array_size] = { 4, 5, 6 };
int array1[array_size];
int array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
boost::swap(array1, array2);
BOOST_CHECK(std::equal(array1, array1 + array_size, initial_array2));

View File

@@ -52,13 +52,13 @@ int main()
const std::size_t array_size = 2;
const swap_test_template<int> initial_array1[array_size] = { { swap_test_class(1) }, { swap_test_class(2) } };
const swap_test_template<int> initial_array2[array_size] = { { swap_test_class(3) }, { swap_test_class(4) } };
swap_test_template<int> array1[array_size];
swap_test_template<int> array2[array_size];
std::copy(initial_array1, initial_array1 + array_size, array1);
std::copy(initial_array2, initial_array2 + array_size, array2);
swap_test_class::reset();
boost::swap(array1, array2);

View File

@@ -6,7 +6,7 @@
namespace boost
{
template<class T> struct Wrapper
{
T value;
@@ -16,9 +16,9 @@ template<class T> inline void swap( Wrapper<T> & w, Wrapper<T> & v )
{
boost::swap( w, v );
}
} // namespace boost
int main()
{
boost::Wrapper<int> const w = { 2 };

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2023 Andrey Semashev
//
// 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)
// Tests that boost::swap propagates noexcept specification correctly
#include <boost/core/swap.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) && \
!(defined(BOOST_GCC) && (BOOST_GCC < 40700))
namespace test_ns {
struct class_with_noexcept_swap
{
static class_with_noexcept_swap& instance() noexcept;
friend void swap(class_with_noexcept_swap&, class_with_noexcept_swap&) noexcept
{
}
};
struct class_with_except_swap
{
static class_with_except_swap& instance() noexcept;
friend void swap(class_with_except_swap&, class_with_except_swap&)
{
}
};
} // namespace test_ns
static_assert(noexcept(boost::swap(test_ns::class_with_noexcept_swap::instance(), test_ns::class_with_noexcept_swap::instance())),
"boost::swap for class_with_noexcept_swap should have noexcept specification");
static_assert(!noexcept(boost::swap(test_ns::class_with_except_swap::instance(), test_ns::class_with_except_swap::instance())),
"boost::swap for class_with_except_swap should not have noexcept specification");
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) ...

View File

@@ -31,7 +31,7 @@ int main()
boost::swap_test_class object1 = initial_value1;
boost::swap_test_class object2 = initial_value2;
boost::swap_test_class::reset();
boost::swap(object1,object2);

View File

@@ -10,7 +10,7 @@
// in an other namespace to have a custom swap function in boost, because the
// boost::swap utility should find the swap function in the other namespace, by
// argument dependent lookup (ADL). Unfortunately ADL isn't fully implemented
// by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1, and
// by some specific compiler versions, including Intel C++ 8.1, MSVC 7.1, and
// Borland 5.9.3. Users of those compilers might consider adding a swap overload
// to the boost namespace.
@@ -50,13 +50,13 @@ int main()
other::swap_test_class object1 = initial_value1;
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0);

View File

@@ -25,13 +25,13 @@ int main()
swap_test_class object1 = initial_value1;
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);

View File

@@ -31,13 +31,13 @@ int main()
other::swap_test_class object1 = initial_value1;
other::swap_test_class object2 = initial_value2;
other::swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0);

View File

@@ -30,13 +30,13 @@ int main()
swap_test_class object1 = initial_value1;
swap_test_class object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);

View File

@@ -19,7 +19,7 @@ int main()
{
const std::type_info * const initial_value1 = 0;
const std::type_info * const initial_value2 = &typeid(double);
const std::type_info * ptr1 = initial_value1;
const std::type_info * ptr2 = initial_value2;

View File

@@ -5,7 +5,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// having boost::swap_test_class as vector element type.
// having boost::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -39,12 +39,12 @@ int main()
const vector_type initial_value1(initial_size1, swap_test_class_type(1));
const vector_type initial_value2(initial_size2, swap_test_class_type(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class_type::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);
@@ -52,7 +52,7 @@ int main()
BOOST_CHECK(object1 == initial_value2);
BOOST_CHECK(object2 == initial_value1);
BOOST_CHECK_EQUAL(swap_test_class_type::swap_count(),0);
BOOST_CHECK_EQUAL(swap_test_class_type::copy_count(),0);

View File

@@ -5,7 +5,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// having ::swap_test_class as vector element type.
// having ::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -17,7 +17,7 @@
//Put test class in the global namespace
#include "./swap_test_class.hpp"
//Provide swap function in the global namespace
//Provide swap function in the global namespace
void swap(swap_test_class& left, swap_test_class& right)
{
left.swap(right);
@@ -32,12 +32,12 @@ int main()
const vector_type initial_value1(initial_size1, swap_test_class(1));
const vector_type initial_value2(initial_size2, swap_test_class(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);

View File

@@ -5,7 +5,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
// Tests swapping std::vector objects by means of boost::swap,
// having other::swap_test_class as vector element type.
// having other::swap_test_class as vector element type.
#include <boost/utility/swap.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -39,12 +39,12 @@ int main()
const vector_type initial_value1(initial_size1, swap_test_class_type(1));
const vector_type initial_value2(initial_size2, swap_test_class_type(2));
vector_type object1 = initial_value1;
vector_type object2 = initial_value2;
swap_test_class_type::reset();
boost::swap(object1,object2);
BOOST_CHECK_EQUAL(object1.size(),initial_size2);

View File

@@ -59,7 +59,7 @@ public:
{
m_data = arg;
}
static unsigned int swap_count(){ return swapCount(); }
static unsigned int copy_count(){ return copyCount(); }
static unsigned int construct_count(){ return constructCount(); }
@@ -68,7 +68,7 @@ public:
static void reset()
{
swapCount() = 0;
copyCount() = 0;
copyCount() = 0;
constructCount() = 0;
destructCount() = 0;
}
@@ -80,19 +80,19 @@ private:
return value;
}
static unsigned int& copyCount()
static unsigned int& copyCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& constructCount()
static unsigned int& constructCount()
{
static unsigned int value = 0;
return value;
}
static unsigned int& destructCount()
static unsigned int& destructCount()
{
static unsigned int value = 0;
return value;