Compare commits

..

2 Commits

Author SHA1 Message Date
8c5caaf594 glob headers 2022-07-05 10:48:33 +02:00
6eaae5f10b Rework as esp-idf component 2022-07-04 20:18:27 +02:00
205 changed files with 5107 additions and 2679 deletions

View File

@@ -1,421 +0,0 @@
# Copyright 2022 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
local library = "smart_ptr";
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',
'uname -a',
'echo $DRONE_STAGE_MACHINE',
] +
(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.8*",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11' },
),
linux_pipeline(
"Linux 14.04 GCC 4.9",
"cppalliance/droneubuntu1404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-4.9', CXXSTD: '11' },
"g++-4.9",
[ "ppa:ubuntu-toolchain-r/test" ],
),
linux_pipeline(
"Linux 16.04 GCC 5*",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14' },
),
linux_pipeline(
"Linux 18.04 GCC 6",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-6', CXXSTD: '11,14' },
"g++-6",
),
linux_pipeline(
"Linux 18.04 GCC 7* 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 18.04 GCC 8 32/64",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-8', CXXSTD: '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: '11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 20.04 GCC 9* ARM64",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
arch="arm64",
),
linux_pipeline(
"Linux 20.04 GCC 9* S390x",
"cppalliance/droneubuntu2004:multiarch",
{ TOOLSET: 'gcc', COMPILER: 'g++', CXXSTD: '11,14,17,2a' },
arch="s390x",
),
linux_pipeline(
"Linux 20.04 GCC 10 32/64",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-10', CXXSTD: '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: '11,14,17,2a', ADDRMD: '32,64' },
),
linux_pipeline(
"Linux 22.04 GCC 12 32/64",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-12', CXXSTD: '11,14,17,20,2b', ADDRMD: '32,64' },
"g++-12-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 32 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + asan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 32 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '32' } + ubsan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 13 64 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-13', CXXSTD: '11,14,17,20,2b', ADDRMD: '64' } + ubsan,
"g++-13-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + ubsan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 24.04 GCC 14 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'gcc', COMPILER: 'g++-14', CXXSTD: '11,14,17,20,2b' } + asan,
"g++-14-multilib",
),
linux_pipeline(
"Linux 16.04 Clang 3.5",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.5', CXXSTD: '11' },
"clang-3.5",
),
linux_pipeline(
"Linux 16.04 Clang 3.6",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.6', CXXSTD: '11,14' },
"clang-3.6",
),
linux_pipeline(
"Linux 16.04 Clang 3.7",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.7', CXXSTD: '11,14' },
"clang-3.7",
),
linux_pipeline(
"Linux 16.04 Clang 3.8",
"cppalliance/droneubuntu1604:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.8', CXXSTD: '11,14' },
"clang-3.8",
),
linux_pipeline(
"Linux 18.04 Clang 3.9",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-3.9', CXXSTD: '11,14' },
"clang-3.9",
),
linux_pipeline(
"Linux 18.04 Clang 4.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-4.0', CXXSTD: '11,14' },
"clang-4.0",
),
linux_pipeline(
"Linux 18.04 Clang 5.0",
"cppalliance/droneubuntu1804:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-5.0', CXXSTD: '11,14' },
"clang-5.0",
),
linux_pipeline(
"Linux 20.04 Clang 6.0",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-6.0', CXXSTD: '11,14,17' },
"clang-6.0",
),
linux_pipeline(
"Linux 20.04 Clang 7",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-7', CXXSTD: '11,14,17' },
"clang-7",
),
linux_pipeline(
"Linux 20.04 Clang 8",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-8', CXXSTD: '11,14,17' },
"clang-8",
),
linux_pipeline(
"Linux 20.04 Clang 9",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-9', CXXSTD: '11,14,17,2a' },
"clang-9",
),
linux_pipeline(
"Linux 20.04 Clang 10",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-10', CXXSTD: '11,14,17,2a' },
"clang-10",
),
linux_pipeline(
"Linux 20.04 Clang 11",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-11', CXXSTD: '11,14,17,2a' },
"clang-11",
),
linux_pipeline(
"Linux 20.04 Clang 12",
"cppalliance/droneubuntu2004:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-12', CXXSTD: '11,14,17,20' },
"clang-12",
),
linux_pipeline(
"Linux 22.04 Clang 13",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-13', CXXSTD: '11,14,17,20,2b' },
"clang-13",
),
linux_pipeline(
"Linux 22.04 Clang 14",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-14', CXXSTD: '11,14,17,20,2b' },
"clang-14",
),
linux_pipeline(
"Linux 22.04 Clang 15",
"cppalliance/droneubuntu2204:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-15', CXXSTD: '11,14,17,20,2b' },
"clang-15",
),
linux_pipeline(
"Linux 24.04 Clang 16",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
"clang-16",
),
linux_pipeline(
"Linux 24.04 Clang 17",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
"clang-17",
),
linux_pipeline(
"Linux 24.04 Clang 18",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' },
"clang-18",
),
linux_pipeline(
"Linux 24.04 Clang 19",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
"clang-19",
),
linux_pipeline(
"Linux 24.04 Clang 20 UBSAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + ubsan,
"clang-20",
),
linux_pipeline(
"Linux 24.04 Clang 20 ASAN",
"cppalliance/droneubuntu2404:1",
{ TOOLSET: 'clang', COMPILER: 'clang++-20', CXXSTD: '11,14,17,20,23,2c' } + asan,
"clang-20",
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
),
macos_pipeline(
"MacOS 10.15 Xcode 12.2 ASAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + asan,
),
macos_pipeline(
"MacOS 12.4 Xcode 13.4.1 UBSAN",
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '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: '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', B2_DONT_EMBED_MANIFEST: '1' },
),
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' },
),
]

View File

@@ -1,23 +0,0 @@
@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 %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

View File

@@ -1,25 +0,0 @@
#!/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 $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

@@ -18,226 +18,119 @@ jobs:
matrix:
include:
- toolset: gcc-4.8
cxxstd: "11"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "11,14,17"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "11,14,17,20"
os: ubuntu-22.04
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11-multilib
address-model: 32,64
- toolset: gcc-12
cxxstd: "11,14,17,20,2b"
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: g++-12-multilib
address-model: 32,64
- toolset: gcc-13
cxxstd: "11,14,17,20,2b"
os: ubuntu-latest
container: ubuntu:24.04
install: g++-13-multilib
address-model: 32,64
- toolset: gcc-14
cxxstd: "11,14,17,20,23,2c"
os: ubuntu-latest
container: ubuntu:24.04
install: g++-14-multilib
address-model: 32,64
- toolset: gcc-15
cxxstd: "11,14,17,20,23,2c"
os: ubuntu-latest
container: ubuntu:25.04
install: g++-15-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "11,14"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "11,14"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "11,14,1z"
container: ubuntu:18.04
os: ubuntu-latest
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "11,14,17"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-11
cxxstd: "11,14,17,2a"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-12
cxxstd: "11,14,17,20"
container: ubuntu:20.04
os: ubuntu-latest
install: clang-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
- toolset: clang
compiler: clang++-13
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-13
- toolset: clang
compiler: clang++-14
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
cxxstd: "03,11,14,17,20"
os: ubuntu-22.04
install: clang-14
- toolset: clang
compiler: clang++-15
cxxstd: "11,14,17,20,2b"
container: ubuntu:22.04
os: ubuntu-latest
install: clang-15
- toolset: clang
compiler: clang++-16
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-16
- toolset: clang
compiler: clang++-17
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-17
- toolset: clang
compiler: clang++-18
cxxstd: "11,14,17,20,2b"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-18
- toolset: clang
compiler: clang++-19
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:24.04
os: ubuntu-latest
install: clang-19
- toolset: clang
compiler: clang++-20
cxxstd: "11,14,17,20,23,2c"
container: ubuntu:25.04
os: ubuntu-latest
install: clang-20
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-13
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-14
- toolset: clang
cxxstd: "11,14,17,20,2b"
os: macos-15
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
container:
image: ${{matrix.container}}
volumes:
- /node20217:/node20217:rw,rshared
- ${{ startsWith(matrix.container, 'ubuntu:1') && '/node20217:/__e/node20:ro,rshared' || ' ' }}
defaults:
run:
shell: bash
steps:
- name: Setup container environment
if: matrix.container
run: |
apt-get update
apt-get -y install sudo python3 git g++ curl xz-utils
- name: Install nodejs20glibc2.17
if: ${{ startsWith( matrix.container, 'ubuntu:1' ) }}
run: |
curl -LO https://archives.boost.io/misc/node/node-v20.9.0-linux-x64-glibc-217.tar.xz
tar -xf node-v20.9.0-linux-x64-glibc-217.tar.xz --strip-components 1 -C /node20217
ldd /__e/node20/bin/node
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: |
sudo apt-get update
sudo apt-get -y install ${{matrix.install}}
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
@@ -257,7 +150,7 @@ jobs:
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python3 tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
@@ -276,23 +169,31 @@ jobs:
fail-fast: false
matrix:
include:
- toolset: msvc-14.0
cxxstd: 14,latest
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.2
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,20,latest"
addrmd: 32,64
os: windows-2022
- toolset: clang-win
cxxstd: "14,17,20,latest"
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "11,14,17,2a"
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2022
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
@@ -327,20 +228,19 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
@@ -375,20 +275,19 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
@@ -433,20 +332,19 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: ubuntu-22.04
- os: ubuntu-24.04
- os: macos-13
- os: macos-14
- os: macos-15
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt-get -y install ${{matrix.install}}
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
@@ -483,180 +381,3 @@ jobs:
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error
windows-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Use library with add_subdirectory (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use library with add_subdirectory (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_subdir_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
- name: Install (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Debug
- name: Install (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target install --config Release
- name: Use the installed library (Debug)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=C:/cmake-prefix ..
cmake --build . --config Debug
ctest --output-on-failure --no-tests=error -C Debug
- name: Use the installed library (Release)
shell: cmd
run: |
cd ../boost-root/libs/%LIBRARY%/test/cmake_install_test/__build__
cmake --build . --config Release
ctest --output-on-failure --no-tests=error -C Release
windows-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
- name: Configure
shell: cmd
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=%LIBRARY% -DBUILD_TESTING=ON ..
- name: Build tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Debug
- name: Run tests (Debug)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Debug
- name: Build tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
cmake --build . --target tests --config Release
- name: Run tests (Release)
shell: cmd
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error -C Release

View File

@@ -1,9 +1,10 @@
# Generated by `boostdep --cmake smart_ptr`
# Copyright 2020, 2021 Peter Dimov
# Copyright 2018-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8...3.20)
if(NOT DEFINED IDF_TARGET)
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_smart_ptr VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
@@ -17,13 +18,36 @@ target_link_libraries(boost_smart_ptr
Boost::assert
Boost::config
Boost::core
Boost::move
Boost::static_assert
Boost::throw_exception
Boost::type_traits
)
target_compile_features(boost_smart_ptr INTERFACE cxx_std_11)
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
if(BUILD_TESTING)
add_subdirectory(test)
endif()
else()
FILE(GLOB_RECURSE headers include/*.h include/*.hpp)
idf_component_register(
SRCS
${headers}
INCLUDE_DIRS
include
REQUIRES
boost_assert
boost_config
boost_core
boost_move
boost_static_assert
boost_throw_exception
boost_type_traits
)
endif()

View File

@@ -15,28 +15,15 @@ branches:
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 20
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: latest
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: clang-win
CXXSTD: 14,17,latest
@@ -44,19 +31,19 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 11,14,1z
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
ADDPATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 11,14,17
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 11,14,17
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
@@ -64,9 +51,25 @@ install:
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule init libs/align
- git submodule init libs/assert
- git submodule init libs/atomic
- git submodule init libs/config
- git submodule init libs/container_hash
- git submodule init libs/core
- git submodule init libs/move
- git submodule init libs/predef
- git submodule init libs/static_assert
- git submodule init libs/throw_exception
- git submodule init libs/type_traits
- git submodule init libs/detail
- git submodule init libs/integer
- git submodule init tools/build
- git submodule init libs/headers
- git submodule init tools/boost_install
- git submodule init libs/bind
- git submodule update --jobs 3
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\smart_ptr\
- git submodule update --init tools/boostdep
- python tools/boostdep/depinst/depinst.py smart_ptr
- cmd /c bootstrap
- b2 -d0 headers

View File

@@ -1,23 +0,0 @@
# Copyright 2023-2024 René Ferdinand Rivera Morell
# Copyright 2024 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
require-b2 5.2 ;
constant boost_dependencies :
/boost/assert//boost_assert
/boost/config//boost_config
/boost/core//boost_core
/boost/throw_exception//boost_throw_exception
;
project /boost/smart_ptr ;
explicit
[ alias boost_smart_ptr : : : : <include>include <library>$(boost_dependencies) ]
[ alias all : boost_smart_ptr test ]
;
call-if : boost-library smart_ptr
;

View File

@@ -1,5 +1,5 @@
////
Copyright 2019-2025 Peter Dimov
Copyright 2019, 2020 Peter Dimov
Distributed under the Boost Software License, Version 1.0.
@@ -13,20 +13,6 @@ http://www.boost.org/LICENSE_1_0.txt
:toc-title:
:idprefix: changelog_
## Changes in 1.88.0
* Fix `operator<<` for wide streams (accidentally broken in 1.87.0)
## Changes in 1.87.0
* {cpp}03 is no longer supported, a {cpp}11 compiler is required.
This includes GCC 4.8 or later, and MSVC 14.0 or later.
* The functionality enabled by the macros `BOOST_SP_ENABLE_DEBUG_HOOKS`,
`BOOST_SP_USE_STD_ALLOCATOR`, `BOOST_SP_USE_QUICK_ALLOCATOR`,
`BOOST_AC_USE_SPINLOCK`, `BOOST_AC_USE_PTHREADS`, `BOOST_SP_USE_SPINLOCK`,
and `BOOST_SP_USE_PTHREADS` has been deprecated and support for it
will be removed in a future release.
## Changes in 1.79.0
* Added `get_allocator_pointer`

View File

@@ -30,8 +30,8 @@ requests from users.
This library also provides additional overloads of `make_unique` for
default-initialization, when users do not need or want to incur the expense
of value-initialization. The {cpp}20 standard now provides this feature with
`std::make_unique_for_overwrite`.
of value-initialization. The {cpp} standard does not yet provide this
feature with `std::make_unique`.
## Synopsis

View File

@@ -210,8 +210,7 @@ T* get() const noexcept;
[none]
* {blank}
+
Returns::
The stored pointer.
Returns:: The stored pointer.
### unique
@@ -221,8 +220,8 @@ bool unique() const noexcept;
[none]
* {blank}
+
Returns::
`true` if no other `shared_array` is sharing ownership of the stored pointer, `false` otherwise.
Returns:: `true` if no other `shared_array` is sharing ownership of the
stored pointer, `false` otherwise.
### use_count
@@ -254,8 +253,7 @@ void swap(shared_array<T>& b) noexcept;
[none]
* {blank}
+
Effects::
Exchanges the contents of the two smart pointers.
Effects:: Exchanges the contents of the two smart pointers.
## Free Functions

270
extras/src/sp_collector.cpp Normal file
View File

@@ -0,0 +1,270 @@
//
// sp_collector.cpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// 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)
//
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
#include <boost/assert.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <cstdlib>
#include <map>
#include <deque>
#include <iostream>
typedef std::map< void const *, std::pair<void *, size_t> > map_type;
static map_type & get_map()
{
static map_type m;
return m;
}
typedef boost::detail::lightweight_mutex mutex_type;
static mutex_type & get_mutex()
{
static mutex_type m;
return m;
}
static void * init_mutex_before_main = &get_mutex();
namespace
{
class X;
struct count_layout
{
boost::detail::sp_counted_base * pi;
int id;
};
struct shared_ptr_layout
{
X * px;
count_layout pn;
};
}
// assume 4 byte alignment for pointers when scanning
size_t const pointer_align = 4;
typedef std::map<void const *, long> map2_type;
static void scan_and_count(void const * area, size_t size, map_type const & m, map2_type & m2)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m.count(q->pn.pi) != 0)
{
++m2[q->pn.pi];
}
}
}
typedef std::deque<void const *> open_type;
static void scan_and_mark(void const * area, size_t size, map2_type & m2, open_type & open)
{
unsigned char const * p = static_cast<unsigned char const *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout const * q = reinterpret_cast<shared_ptr_layout const *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0)
{
open.push_back(q->pn.pi);
m2.erase(q->pn.pi);
}
}
}
static void find_unreachable_objects_impl(map_type const & m, map2_type & m2)
{
// scan objects for shared_ptr members, compute internal counts
{
std::cout << "... " << m.size() << " objects in m.\n";
for(map_type::const_iterator i = m.begin(); i != m.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
BOOST_ASSERT(p->use_count() != 0); // there should be no inactive counts in the map
m2[ i->first ];
scan_and_count(i->second.first, i->second.second, m, m2);
}
std::cout << "... " << m2.size() << " objects in m2.\n";
}
// mark reachable objects
{
open_type open;
for(map2_type::iterator i = m2.begin(); i != m2.end(); ++i)
{
boost::detail::sp_counted_base const * p = static_cast<boost::detail::sp_counted_base const *>(i->first);
if(p->use_count() != i->second) open.push_back(p);
}
std::cout << "... " << open.size() << " objects in open.\n";
for(open_type::iterator j = open.begin(); j != open.end(); ++j)
{
m2.erase(*j);
}
while(!open.empty())
{
void const * p = open.front();
open.pop_front();
map_type::const_iterator i = m.find(p);
BOOST_ASSERT(i != m.end());
scan_and_mark(i->second.first, i->second.second, m2, open);
}
}
// m2 now contains the unreachable objects
}
std::size_t find_unreachable_objects(bool report)
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
// This will work without the #ifdef, but some compilers warn
// that lock is not referenced
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
if(report)
{
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
std::cout << "Unreachable object at " << i->second.first << ", " << i->second.second << " bytes long.\n";
}
}
return m2.size();
}
typedef std::deque< boost::shared_ptr<X> > free_list_type;
static void scan_and_free(void * area, size_t size, map2_type const & m2, free_list_type & free)
{
unsigned char * p = static_cast<unsigned char *>(area);
for(size_t n = 0; n + sizeof(shared_ptr_layout) <= size; p += pointer_align, n += pointer_align)
{
shared_ptr_layout * q = reinterpret_cast<shared_ptr_layout *>(p);
if(q->pn.id == boost::detail::shared_count_id && q->pn.pi != 0 && m2.count(q->pn.pi) != 0 && q->px != 0)
{
boost::shared_ptr<X> * ppx = reinterpret_cast< boost::shared_ptr<X> * >(p);
free.push_back(*ppx);
ppx->reset();
}
}
}
void free_unreachable_objects()
{
free_list_type free;
{
map2_type m2;
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
map_type const & m = get_map();
find_unreachable_objects_impl(m, m2);
for(map2_type::iterator j = m2.begin(); j != m2.end(); ++j)
{
map_type::const_iterator i = m.find(j->first);
BOOST_ASSERT(i != m.end());
scan_and_free(i->second.first, i->second.second, m2, free);
}
}
std::cout << "... about to free " << free.size() << " objects.\n";
}
// debug hooks
namespace boost
{
void sp_scalar_constructor_hook(void *)
{
}
void sp_scalar_constructor_hook(void * px, std::size_t size, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map()[pn] = std::make_pair(px, size);
}
void sp_scalar_destructor_hook(void *)
{
}
void sp_scalar_destructor_hook(void *, std::size_t, void * pn)
{
#ifdef BOOST_HAS_THREADS
mutex_type::scoped_lock lock(get_mutex());
#endif
get_map().erase(pn);
}
void sp_array_constructor_hook(void *)
{
}
void sp_array_destructor_hook(void *)
{
}
} // namespace boost
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)

View File

@@ -0,0 +1,243 @@
//
// sp_debug_hooks.cpp
//
// Copyright (c) 2002, 2003 Peter Dimov
//
// 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)
//
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
#include <boost/assert.hpp>
#include <new>
#include <cstdlib>
int const m = 2; // m * sizeof(int) must be aligned appropriately
// magic values to mark heap blocks with
int const allocated_scalar = 0x1234560C;
int const allocated_array = 0x1234560A;
int const adopted_scalar = 0x0567890C;
int const adopted_array = 0x0567890A;
int const deleted = 0x498769DE;
using namespace std; // for compilers where things aren't in std
// operator new
static new_handler get_new_handler()
{
new_handler p = set_new_handler(0);
set_new_handler(p);
return p;
}
static void * allocate(size_t n, int mark)
{
int * pm;
for(;;)
{
pm = static_cast<int*>(malloc(n + m * sizeof(int)));
if(pm != 0) break;
if(new_handler pnh = get_new_handler())
{
pnh();
}
else
{
return 0;
}
}
*pm = mark;
return pm + m;
}
void * operator new(size_t n) throw(bad_alloc)
{
void * p = allocate(n, allocated_scalar);
#if !defined(BOOST_NO_EXCEPTIONS)
if(p == 0) throw bad_alloc();
#endif
return p;
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void * operator new(size_t n, nothrow_t const &) throw()
{
return allocate(n, allocated_scalar);
}
#endif
void * operator new[](size_t n) throw(bad_alloc)
{
void * p = allocate(n, allocated_array);
#if !defined(BOOST_NO_EXCEPTIONS)
if(p == 0) throw bad_alloc();
#endif
return p;
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void * operator new[](size_t n, nothrow_t const &) throw()
{
return allocate(n, allocated_array);
}
#endif
// debug hooks
namespace boost
{
void sp_scalar_constructor_hook(void * p)
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != adopted_scalar); // second smart pointer to the same address
BOOST_ASSERT(*pm != allocated_array); // allocated with new[]
BOOST_ASSERT(*pm == allocated_scalar); // not allocated with new
*pm = adopted_scalar;
}
void sp_scalar_constructor_hook(void * px, std::size_t, void *)
{
sp_scalar_constructor_hook(px);
}
void sp_scalar_destructor_hook(void * p)
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm == adopted_scalar); // attempt to destroy nonmanaged block
*pm = allocated_scalar;
}
void sp_scalar_destructor_hook(void * px, std::size_t, void *)
{
sp_scalar_destructor_hook(px);
}
// It is not possible to handle the array hooks in a portable manner.
// The implementation typically reserves a bit of storage for the number
// of objects in the array, and the argument of the array hook isn't
// equal to the return value of operator new[].
void sp_array_constructor_hook(void * /* p */)
{
/*
if(p == 0) return;
// adjust p depending on the implementation
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != adopted_array); // second smart array pointer to the same address
BOOST_ASSERT(*pm != allocated_scalar); // allocated with new
BOOST_ASSERT(*pm == allocated_array); // not allocated with new[]
*pm = adopted_array;
*/
}
void sp_array_destructor_hook(void * /* p */)
{
/*
if(p == 0) return;
// adjust p depending on the implementation
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm == adopted_array); // attempt to destroy nonmanaged block
*pm = allocated_array;
*/
}
} // namespace boost
// operator delete
void operator delete(void * p) throw()
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != deleted); // double delete
BOOST_ASSERT(*pm != adopted_scalar); // delete p.get();
BOOST_ASSERT(*pm != allocated_array); // allocated with new[]
BOOST_ASSERT(*pm == allocated_scalar); // not allocated with new
*pm = deleted;
free(pm);
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void operator delete(void * p, nothrow_t const &) throw()
{
::operator delete(p);
}
#endif
void operator delete[](void * p) throw()
{
if(p == 0) return;
int * pm = static_cast<int*>(p);
pm -= m;
BOOST_ASSERT(*pm != deleted); // double delete
BOOST_ASSERT(*pm != adopted_scalar); // delete p.get();
BOOST_ASSERT(*pm != allocated_scalar); // allocated with new
BOOST_ASSERT(*pm == allocated_array); // not allocated with new[]
*pm = deleted;
free(pm);
}
#if !defined(BOOST_BORLANDC) || (BOOST_BORLANDC > 0x551)
void operator delete[](void * p, nothrow_t const &) throw()
{
::operator delete[](p);
}
#endif
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)

View File

@@ -1,3 +1,12 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
// shared_ptr_mt_test.cpp - tests shared_ptr with multiple threads
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
@@ -9,14 +18,14 @@
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
#include <vector>
#include <cstdio>
#include <ctime>
#include <boost/detail/lightweight_thread.hpp>
//
int const n = 1024 * 1024;

View File

@@ -1,3 +1,12 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// shared_ptr_timing_test.cpp - use to evaluate the impact of thread safety
//

View File

@@ -13,8 +13,8 @@
#include <boost/thread/shared_mutex.hpp>
#include <boost/thread/locks.hpp>
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <boost/detail/lightweight_thread.hpp>
#include <vector>
#include <numeric>

View File

@@ -18,9 +18,9 @@
#include <boost/thread/locks.hpp>
#endif
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/detail/lightweight_mutex.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <boost/detail/lightweight_thread.hpp>
#include <cstdio>
#include <ctime>

View File

@@ -1,3 +1,12 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
// weak_ptr_mt_test.cpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
@@ -10,15 +19,15 @@
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/bind.hpp>
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/lightweight_thread.hpp>
#include <vector>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <boost/detail/lightweight_thread.hpp>
//
int const n = 16384;

View File

@@ -1,3 +1,12 @@
#include <boost/config.hpp>
#if defined(BOOST_MSVC)
#pragma warning(disable: 4786) // identifier truncated in debug info
#pragma warning(disable: 4710) // function not inlined
#pragma warning(disable: 4711) // function selected for automatic inline expansion
#pragma warning(disable: 4514) // unreferenced inline removed
#endif
//
// weak_ptr_timing_test.cpp
//
@@ -11,7 +20,6 @@
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/config.hpp>
#include <vector>
#include <cstdio>

View File

@@ -1,13 +1,20 @@
#ifndef BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
#define BOOST_DETAIL_ATOMIC_COUNT_HPP_INCLUDED
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// MS compatible compilers support #pragma once
#include <boost/config/header_deprecated.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
BOOST_HEADER_DEPRECATED("<boost/smart_ptr/detail/atomic_count.hpp>")
//
// boost/detail/atomic_count.hpp - thread/SMP safe reference counter
//
// Copyright (c) 2001, 2002 Peter Dimov and Multi Media Ltd.
//
// 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
#include <boost/smart_ptr/detail/atomic_count.hpp>

View File

@@ -1,13 +1,21 @@
#ifndef BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
#define BOOST_DETAIL_LIGHTWEIGHT_MUTEX_HPP_INCLUDED
// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// MS compatible compilers support #pragma once
#include <boost/config/header_deprecated.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
BOOST_HEADER_DEPRECATED("<boost/smart_ptr/detail/lightweight_mutex.hpp>")
//
// boost/detail/lightweight_mutex.hpp - lightweight mutex
//
// Copyright (c) 2002, 2003 Peter Dimov and Multi Media Ltd.
//
// 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
//
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>

View File

@@ -1,14 +1,25 @@
#ifndef BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
#define BOOST_DETAIL_LIGHTWEIGHT_THREAD_HPP_INCLUDED
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008, 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// MS compatible compilers support #pragma once
#include <boost/config/header_deprecated.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
BOOST_HEADER_DEPRECATED("<boost/smart_ptr/detail/lightweight_thread.hpp>")
// boost/detail/lightweight_thread.hpp
//
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
// Copyright (c) 2008, 2018 Peter Dimov
//
// 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
//
//
// typedef /*...*/ lw_thread_t; // as pthread_t
// template<class F> int lw_thread_create( lw_thread_t & th, F f );
// void lw_thread_join( lw_thread_t th );
#include <boost/smart_ptr/detail/lightweight_thread.hpp>

View File

@@ -1,14 +1,22 @@
#ifndef BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
#define BOOST_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
// Copyright (c) 2003 David Abrahams
// Copyright (c) 2003 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// MS compatible compilers support #pragma once
#include <boost/config/header_deprecated.hpp>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
BOOST_HEADER_DEPRECATED("<boost/smart_ptr/detail/quick_allocator.hpp>")
//
// detail/quick_allocator.hpp
//
// Copyright (c) 2003 David Abrahams
// Copyright (c) 2003 Peter Dimov
//
// 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
//
#include <boost/smart_ptr/detail/quick_allocator.hpp>

View File

@@ -10,39 +10,49 @@
#ifndef BOOST_POINTER_CAST_HPP
#define BOOST_POINTER_CAST_HPP
#include <memory>
#include <type_traits>
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
namespace boost {
//static_pointer_cast overload for raw pointers
template<class T, class U>
inline T* static_pointer_cast(U *ptr) noexcept
inline T* static_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return static_cast<T*>(ptr);
}
//dynamic_pointer_cast overload for raw pointers
template<class T, class U>
inline T* dynamic_pointer_cast(U *ptr) noexcept
inline T* dynamic_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return dynamic_cast<T*>(ptr);
}
//const_pointer_cast overload for raw pointers
template<class T, class U>
inline T* const_pointer_cast(U *ptr) noexcept
inline T* const_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return const_cast<T*>(ptr);
}
//reinterpret_pointer_cast overload for raw pointers
template<class T, class U>
inline T* reinterpret_pointer_cast(U *ptr) noexcept
inline T* reinterpret_pointer_cast(U *ptr) BOOST_SP_NOEXCEPT
{
return reinterpret_cast<T*>(ptr);
}
} // namespace boost
#if !defined( BOOST_NO_CXX11_SMART_PTR )
#include <boost/type_traits/has_virtual_destructor.hpp>
#include <boost/static_assert.hpp>
#include <memory>
namespace boost {
//static_pointer_cast overload for std::shared_ptr
using std::static_pointer_cast;
@@ -53,7 +63,7 @@ using std::dynamic_pointer_cast;
using std::const_pointer_cast;
//reinterpret_pointer_cast overload for std::shared_ptr
template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) noexcept
template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std::shared_ptr<U> & r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@@ -64,7 +74,7 @@ template<class T, class U> std::shared_ptr<T> reinterpret_pointer_cast(const std
}
//static_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_ptr<U> && r ) noexcept
template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) static_cast< T* >( static_cast< U* >( 0 ) );
@@ -74,11 +84,11 @@ template<class T, class U> std::unique_ptr<T> static_pointer_cast( std::unique_p
}
//dynamic_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_ptr<U> && r ) noexcept
template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
static_assert( std::has_virtual_destructor<T>::value, "The target of dynamic_pointer_cast must have a virtual destructor." );
BOOST_STATIC_ASSERT_MSG( boost::has_virtual_destructor<T>::value, "The target of dynamic_pointer_cast must have a virtual destructor." );
T * p = dynamic_cast<T*>( r.get() );
if( p ) r.release();
@@ -86,7 +96,7 @@ template<class T, class U> std::unique_ptr<T> dynamic_pointer_cast( std::unique_
}
//const_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_ptr<U> && r ) noexcept
template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) const_cast< T* >( static_cast< U* >( 0 ) );
@@ -96,7 +106,7 @@ template<class T, class U> std::unique_ptr<T> const_pointer_cast( std::unique_pt
}
//reinterpret_pointer_cast overload for std::unique_ptr
template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::unique_ptr<U> && r ) noexcept
template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::unique_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@@ -107,4 +117,6 @@ template<class T, class U> std::unique_ptr<T> reinterpret_pointer_cast( std::uni
} // namespace boost
#endif // #if !defined( BOOST_NO_CXX11_SMART_PTR )
#endif //BOOST_POINTER_CAST_HPP

View File

@@ -10,8 +10,6 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/allocate_shared_array.hpp>
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <type_traits>
namespace boost {
namespace detail {
@@ -19,16 +17,16 @@ namespace detail {
class BOOST_SYMBOL_VISIBLE lsp_array_base
: public local_counted_base {
public:
void set(sp_counted_base* base) noexcept {
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
count_ = shared_count(base);
}
void local_cb_destroy() noexcept override {
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
shared_count().swap(count_);
}
shared_count local_cb_get_shared_count() const
noexcept override {
BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return count_;
}
@@ -41,10 +39,10 @@ class lsp_array_state
: public sp_array_state<A> {
public:
template<class U>
lsp_array_state(const U& other, std::size_t size) noexcept
lsp_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_array_state<A>(other, size) { }
lsp_array_base& base() noexcept {
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
@@ -57,10 +55,10 @@ class lsp_size_array_state
: public sp_size_array_state<A, N> {
public:
template<class U>
lsp_size_array_state(const U& other, std::size_t size) noexcept
lsp_size_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_size_array_state<A, N>(other, size) { }
lsp_array_base& base() noexcept {
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
@@ -71,7 +69,7 @@ private:
} /* detail */
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator, std::size_t count)
{
@@ -91,12 +89,12 @@ allocate_local_shared(const A& allocator, std::size_t count)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator)
{
enum {
count = std::extent<T>::value
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
@@ -114,10 +112,10 @@ allocate_local_shared(const A& allocator)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator, std::size_t count,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
@@ -135,13 +133,13 @@ allocate_local_shared(const A& allocator, std::size_t count,
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared(const A& allocator,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
enum {
count = std::extent<T>::value
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
@@ -159,7 +157,7 @@ allocate_local_shared(const A& allocator,
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared_noinit(const A& allocator, std::size_t count)
{
@@ -168,7 +166,7 @@ allocate_local_shared_noinit(const A& allocator, std::size_t count)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
allocate_local_shared_noinit(const A& allocator)
{

View File

@@ -12,16 +12,22 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/alloc_construct.hpp>
#include <boost/core/first_scalar.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <type_traits>
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/extent.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
namespace boost {
namespace detail {
template<class T>
struct sp_array_element {
typedef typename std::remove_cv<typename
std::remove_extent<T>::type>::type type;
typedef typename boost::remove_cv<typename
boost::remove_extent<T>::type>::type type;
};
template<class T>
@@ -53,8 +59,8 @@ struct sp_align_up {
};
template<class T>
constexpr inline std::size_t
sp_objects(std::size_t size) noexcept
BOOST_CONSTEXPR inline std::size_t
sp_objects(std::size_t size) BOOST_SP_NOEXCEPT
{
return (size + sizeof(T) - 1) / sizeof(T);
}
@@ -65,15 +71,15 @@ public:
typedef A type;
template<class U>
sp_array_state(const U& _allocator, std::size_t _size) noexcept
sp_array_state(const U& _allocator, std::size_t _size) BOOST_SP_NOEXCEPT
: allocator_(_allocator),
size_(_size) { }
A& allocator() noexcept {
A& allocator() BOOST_SP_NOEXCEPT {
return allocator_;
}
std::size_t size() const noexcept {
std::size_t size() const BOOST_SP_NOEXCEPT {
return size_;
}
@@ -88,14 +94,14 @@ public:
typedef A type;
template<class U>
sp_size_array_state(const U& _allocator, std::size_t) noexcept
sp_size_array_state(const U& _allocator, std::size_t) BOOST_SP_NOEXCEPT
: allocator_(_allocator) { }
A& allocator() noexcept {
A& allocator() BOOST_SP_NOEXCEPT {
return allocator_;
}
constexpr std::size_t size() const noexcept {
BOOST_CONSTEXPR std::size_t size() const BOOST_SP_NOEXCEPT {
return N;
}
@@ -106,8 +112,8 @@ private:
template<class T, class U>
struct sp_array_alignment {
enum {
value = sp_max_size<std::alignment_of<T>::value,
std::alignment_of<U>::value>::value
value = sp_max_size<boost::alignment_of<T>::value,
boost::alignment_of<U>::value>::value
};
};
@@ -120,7 +126,7 @@ struct sp_array_offset {
template<class U, class T>
inline U*
sp_array_start(T* base) noexcept
sp_array_start(T* base) BOOST_SP_NOEXCEPT
{
enum {
size = sp_array_offset<T, U>::value
@@ -136,12 +142,12 @@ class sp_array_creator {
offset = sp_array_offset<T, element>::value
};
typedef typename sp_type_with_alignment<sp_array_alignment<T,
typedef typename boost::type_with_alignment<sp_array_alignment<T,
element>::value>::type type;
public:
template<class U>
sp_array_creator(const U& other, std::size_t size) noexcept
sp_array_creator(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: other_(other),
size_(sp_objects<type>(offset + sizeof(element) * size)) { }
@@ -185,33 +191,33 @@ public:
boost::first_scalar(&list), count);
}
T& state() noexcept {
T& state() BOOST_SP_NOEXCEPT {
return state_;
}
void dispose() noexcept override {
void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
boost::alloc_destroy_n(state_.allocator(),
boost::first_scalar(sp_array_start<type>(this)),
state_.size() * sp_array_count<type>::value);
}
void destroy() noexcept override {
void destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
sp_array_creator<allocator, sp_array_base> other(state_.allocator(),
state_.size());
this->~sp_array_base();
other.destroy(this);
}
void* get_deleter(const sp_typeinfo_&) noexcept override {
void* get_deleter(const sp_typeinfo_&) BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
void* get_local_deleter(const sp_typeinfo_&)
noexcept override {
BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
void* get_untyped_deleter() noexcept override {
void* get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE {
return 0;
}
@@ -233,11 +239,11 @@ public:
}
}
T* get() const noexcept {
T* get() const BOOST_SP_NOEXCEPT {
return result_;
}
void release() noexcept {
void release() BOOST_SP_NOEXCEPT {
result_ = 0;
}
@@ -252,7 +258,7 @@ private:
} /* detail */
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator, std::size_t count)
{
typedef typename detail::sp_array_element<T>::type element;
@@ -269,15 +275,15 @@ allocate_shared(const A& allocator, std::size_t count)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator)
{
enum {
count = std::extent<T>::value
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_size_array_state<other, std::extent<T>::value> state;
typedef detail::sp_size_array_state<other, extent<T>::value> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
@@ -289,9 +295,9 @@ allocate_shared(const A& allocator)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator, std::size_t count,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
@@ -307,16 +313,16 @@ allocate_shared(const A& allocator, std::size_t count,
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared(const A& allocator,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
enum {
count = std::extent<T>::value
count = extent<T>::value
};
typedef typename detail::sp_array_element<T>::type element;
typedef typename allocator_rebind<A, element>::type other;
typedef detail::sp_size_array_state<other, std::extent<T>::value> state;
typedef detail::sp_size_array_state<other, extent<T>::value> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, count);
base* node = result.get();
@@ -328,14 +334,14 @@ allocate_shared(const A& allocator,
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
allocate_shared_noinit(const A& allocator, std::size_t count)
{
return boost::allocate_shared<T>(boost::noinit_adapt(allocator), count);
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
allocate_shared_noinit(const A& allocator)
{
return boost::allocate_shared<T>(boost::noinit_adapt(allocator));

View File

@@ -8,35 +8,42 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_SMART_PTR_ALLOCATE_UNIQUE_HPP
#define BOOST_SMART_PTR_ALLOCATE_UNIQUE_HPP
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/core/allocator_access.hpp>
#include <boost/core/alloc_construct.hpp>
#include <boost/core/empty_value.hpp>
#include <boost/core/first_scalar.hpp>
#include <boost/core/noinit_adaptor.hpp>
#include <boost/core/pointer_traits.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/extent.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_bounded_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/type_identity.hpp>
#include <boost/config.hpp>
#include <memory>
#include <utility>
#include <cstddef>
#include <type_traits>
namespace boost {
namespace detail {
template<class T>
struct sp_alloc_size {
static constexpr std::size_t value = 1;
BOOST_STATIC_CONSTEXPR std::size_t value = 1;
};
template<class T>
struct sp_alloc_size<T[]> {
static constexpr std::size_t value = sp_alloc_size<T>::value;
BOOST_STATIC_CONSTEXPR std::size_t value = sp_alloc_size<T>::value;
};
template<class T, std::size_t N>
struct sp_alloc_size<T[N]> {
static constexpr std::size_t value = N * sp_alloc_size<T>::value;
BOOST_STATIC_CONSTEXPR std::size_t value = N * sp_alloc_size<T>::value;
};
template<class T>
@@ -51,8 +58,8 @@ struct sp_alloc_result<T[N]> {
template<class T>
struct sp_alloc_value {
typedef typename std::remove_cv<typename
std::remove_extent<T>::type>::type type;
typedef typename boost::remove_cv<typename
boost::remove_extent<T>::type>::type type;
};
template<class T, class P>
@@ -60,41 +67,45 @@ class sp_alloc_ptr {
public:
typedef T element_type;
sp_alloc_ptr() noexcept
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
#if defined(BOOST_MSVC) && BOOST_MSVC == 1600
sp_alloc_ptr(T* p) noexcept
: p_(const_cast<typename std::remove_cv<T>::type*>(p)) { }
sp_alloc_ptr(T* p) BOOST_SP_NOEXCEPT
: p_(const_cast<typename boost::remove_cv<T>::type*>(p)) { }
#endif
sp_alloc_ptr(std::size_t, P p) noexcept
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
sp_alloc_ptr(std::nullptr_t) noexcept
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator*() const {
return *p_;
}
T* operator->() const noexcept {
T* operator->() const BOOST_SP_NOEXCEPT {
return boost::to_address(p_);
}
explicit operator bool() const noexcept {
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const noexcept {
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const noexcept {
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
static constexpr std::size_t size() noexcept {
BOOST_STATIC_CONSTEXPR std::size_t size() BOOST_SP_NOEXCEPT {
return 1;
}
@@ -102,7 +113,7 @@ public:
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(1,
std::pointer_traits<P>::pointer_to(const_cast<typename
std::remove_cv<T>::type&>(v)));
boost::remove_cv<T>::type&>(v)));
}
#endif
@@ -115,33 +126,37 @@ class sp_alloc_ptr<T[], P> {
public:
typedef T element_type;
sp_alloc_ptr() noexcept
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
sp_alloc_ptr(std::size_t n, P p) noexcept
sp_alloc_ptr(std::size_t n, P p) BOOST_SP_NOEXCEPT
: p_(p)
, n_(n) { }
sp_alloc_ptr(std::nullptr_t) noexcept
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
}
explicit operator bool() const noexcept {
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const noexcept {
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const noexcept {
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
std::size_t size() const noexcept {
std::size_t size() const BOOST_SP_NOEXCEPT {
return n_;
}
@@ -149,7 +164,7 @@ public:
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(n_,
std::pointer_traits<P>::pointer_to(const_cast<typename
std::remove_cv<T>::type&>(v)));
boost::remove_cv<T>::type&>(v)));
}
#endif
@@ -163,32 +178,36 @@ class sp_alloc_ptr<T[N], P> {
public:
typedef T element_type;
sp_alloc_ptr() noexcept
sp_alloc_ptr() BOOST_SP_NOEXCEPT
: p_() { }
sp_alloc_ptr(std::size_t, P p) noexcept
sp_alloc_ptr(std::size_t, P p) BOOST_SP_NOEXCEPT
: p_(p) { }
sp_alloc_ptr(std::nullptr_t) noexcept
#if !defined(BOOST_NO_CXX11_NULLPTR)
sp_alloc_ptr(detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
: p_() { }
#endif
T& operator[](std::size_t i) const {
return p_[i];
}
explicit operator bool() const noexcept {
#if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
explicit operator bool() const BOOST_SP_NOEXCEPT {
return !!p_;
}
#endif
bool operator!() const noexcept {
bool operator!() const BOOST_SP_NOEXCEPT {
return !p_;
}
P ptr() const noexcept {
P ptr() const BOOST_SP_NOEXCEPT {
return p_;
}
static constexpr std::size_t size() noexcept {
BOOST_STATIC_CONSTEXPR std::size_t size() BOOST_SP_NOEXCEPT {
return N;
}
@@ -196,7 +215,7 @@ public:
static sp_alloc_ptr pointer_to(T& v) {
return sp_alloc_ptr(N,
std::pointer_traits<P>::pointer_to(const_cast<typename
std::remove_cv<T>::type&>(v)));
boost::remove_cv<T>::type&>(v)));
}
#endif
@@ -218,18 +237,19 @@ operator!=(const sp_alloc_ptr<T, P>& lhs, const sp_alloc_ptr<T, P>& rhs)
return !(lhs == rhs);
}
#if !defined(BOOST_NO_CXX11_NULLPTR)
template<class T, class P>
inline bool
operator==(const sp_alloc_ptr<T, P>& lhs,
std::nullptr_t) noexcept
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
{
return !lhs.ptr();
}
template<class T, class P>
inline bool
operator==(std::nullptr_t,
const sp_alloc_ptr<T, P>& rhs) noexcept
operator==(detail::sp_nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !rhs.ptr();
}
@@ -237,23 +257,24 @@ operator==(std::nullptr_t,
template<class T, class P>
inline bool
operator!=(const sp_alloc_ptr<T, P>& lhs,
std::nullptr_t) noexcept
detail::sp_nullptr_t) BOOST_SP_NOEXCEPT
{
return !!lhs.ptr();
}
template<class T, class P>
inline bool
operator!=(std::nullptr_t,
const sp_alloc_ptr<T, P>& rhs) noexcept
operator!=(detail::sp_nullptr_t,
const sp_alloc_ptr<T, P>& rhs) BOOST_SP_NOEXCEPT
{
return !!rhs.ptr();
}
#endif
template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p, std::size_t,
std::false_type)
boost::false_type)
{
boost::alloc_destroy(a, boost::to_address(p));
}
@@ -261,7 +282,7 @@ sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p, std::size_t,
template<class A>
inline void
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p,
std::size_t n, std::true_type)
std::size_t n, boost::true_type)
{
#if defined(BOOST_MSVC) && BOOST_MSVC < 1800
if (!p) {
@@ -286,17 +307,19 @@ public:
typedef detail::sp_alloc_ptr<T,
typename allocator_pointer<allocator>::type> pointer;
explicit alloc_deleter(const allocator& a) noexcept
explicit alloc_deleter(const allocator& a) BOOST_SP_NOEXCEPT
: base(empty_init_t(), a) { }
void operator()(pointer p) {
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), std::is_array<T>());
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), is_array<T>());
base::get().deallocate(p.ptr(), p.size());
}
};
#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
template<class T, class A>
using alloc_noinit_deleter = alloc_deleter<T, noinit_adaptor<A> >;
#endif
namespace detail {
@@ -323,15 +346,15 @@ public:
}
}
typename allocator::value_type* get() const noexcept {
typename allocator::value_type* get() const BOOST_SP_NOEXCEPT {
return boost::to_address(p_);
}
allocator& state() noexcept {
allocator& state() BOOST_SP_NOEXCEPT {
return a_;
}
type release() noexcept {
type release() BOOST_SP_NOEXCEPT {
pointer p = p_;
p_ = pointer();
return type(typename deleter::pointer(n_, p), deleter(a_));
@@ -348,7 +371,7 @@ private:
} /* detail */
template<class T, class A>
inline typename std::enable_if<!std::is_array<T>::value,
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc)
{
@@ -357,8 +380,9 @@ allocate_unique(const A& alloc)
return c.release();
}
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class A, class... Args>
inline typename std::enable_if<!std::is_array<T>::value,
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, Args&&... args)
{
@@ -366,11 +390,12 @@ allocate_unique(const A& alloc, Args&&... args)
boost::alloc_construct(c.state(), c.get(), std::forward<Args>(args)...);
return c.release();
}
#endif
template<class T, class A>
inline typename std::enable_if<!std::is_array<T>::value,
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, typename detail::sp_type_identity<T>::type&& value)
allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
{
detail::sp_alloc_make<T, A> c(alloc, 1);
boost::alloc_construct(c.state(), c.get(), std::move(value));
@@ -378,7 +403,7 @@ allocate_unique(const A& alloc, typename detail::sp_type_identity<T>::type&& val
}
template<class T, class A>
inline typename std::enable_if<!std::is_array<T>::value,
inline typename enable_if_<!is_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc)
{
@@ -386,7 +411,7 @@ allocate_unique_noinit(const A& alloc)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, std::size_t size)
{
@@ -397,19 +422,19 @@ allocate_unique(const A& alloc, std::size_t size)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc)
{
detail::sp_alloc_make<T, A> c(alloc, std::extent<T>::value);
detail::sp_alloc_make<T, A> c(alloc, extent<T>::value);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
detail::sp_alloc_size<T>::value);
return c.release();
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc, std::size_t size)
{
@@ -417,7 +442,7 @@ allocate_unique_noinit(const A& alloc, std::size_t size)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, noinit_adaptor<A> > > >::type
allocate_unique_noinit(const A& alloc)
@@ -426,29 +451,29 @@ allocate_unique_noinit(const A& alloc)
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T, alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc, std::size_t size,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
detail::sp_alloc_make<T, A> c(alloc, size);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
size * detail::sp_alloc_size<T>::value, boost::first_scalar(&value),
detail::sp_alloc_size<typename std::remove_extent<T>::type>::value);
detail::sp_alloc_size<typename remove_extent<T>::type>::value);
return c.release();
}
template<class T, class A>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
std::unique_ptr<typename detail::sp_alloc_result<T>::type,
alloc_deleter<T, A> > >::type
allocate_unique(const A& alloc,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
detail::sp_alloc_make<T, A> c(alloc, std::extent<T>::value);
detail::sp_alloc_make<T, A> c(alloc, extent<T>::value);
boost::alloc_construct_n(c.state(), boost::first_scalar(c.get()),
detail::sp_alloc_size<T>::value, boost::first_scalar(&value),
detail::sp_alloc_size<typename std::remove_extent<T>::type>::value);
detail::sp_alloc_size<typename remove_extent<T>::type>::value);
return c.release();
}
@@ -456,7 +481,7 @@ template<class T, class U, class A>
inline typename allocator_pointer<typename allocator_rebind<A,
typename detail::sp_alloc_value<T>::type>::type>::type
get_allocator_pointer(const std::unique_ptr<T,
alloc_deleter<U, A> >& p) noexcept
alloc_deleter<U, A> >& p) BOOST_NOEXCEPT
{
return p.get().ptr();
}

View File

@@ -33,7 +33,7 @@ private:
private:
bool compare_exchange( shared_ptr<T>& v, shared_ptr<T> w ) noexcept
bool compare_exchange( shared_ptr<T>& v, shared_ptr<T> w ) BOOST_SP_NOEXCEPT
{
l_.lock();
@@ -57,16 +57,39 @@ private:
public:
constexpr atomic_shared_ptr() noexcept: l_ BOOST_DETAIL_SPINLOCK_INIT
#if !defined( BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX ) && !defined( BOOST_NO_CXX11_CONSTEXPR )
constexpr atomic_shared_ptr() BOOST_SP_NOEXCEPT: l_ BOOST_DETAIL_SPINLOCK_INIT
{
}
atomic_shared_ptr( shared_ptr<T> p ) noexcept
atomic_shared_ptr( shared_ptr<T> p ) BOOST_SP_NOEXCEPT
: p_( std::move( p ) ), l_ BOOST_DETAIL_SPINLOCK_INIT
{
}
atomic_shared_ptr& operator=( shared_ptr<T> r ) noexcept
#else
atomic_shared_ptr() BOOST_SP_NOEXCEPT
{
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
std::memcpy( &l_, &init, sizeof( init ) );
}
atomic_shared_ptr( shared_ptr<T> p ) BOOST_SP_NOEXCEPT
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
: p_( std::move( p ) )
#else
: p_( p )
#endif
{
boost::detail::spinlock init = BOOST_DETAIL_SPINLOCK_INIT;
std::memcpy( &l_, &init, sizeof( init ) );
}
#endif
atomic_shared_ptr& operator=( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
@@ -74,120 +97,140 @@ public:
return *this;
}
constexpr bool is_lock_free() const noexcept
BOOST_CONSTEXPR bool is_lock_free() const BOOST_SP_NOEXCEPT
{
return false;
}
shared_ptr<T> load() const noexcept
shared_ptr<T> load() const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
template<class M> shared_ptr<T> load( M ) const noexcept
template<class M> shared_ptr<T> load( M ) const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
operator shared_ptr<T>() const noexcept
operator shared_ptr<T>() const BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
return p_;
}
void store( shared_ptr<T> r ) noexcept
void store( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
template<class M> void store( shared_ptr<T> r, M ) noexcept
template<class M> void store( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
shared_ptr<T> exchange( shared_ptr<T> r ) noexcept
shared_ptr<T> exchange( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
{
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
return std::move( r );
#else
return r;
#endif
}
template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) noexcept
template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
{
{
boost::detail::spinlock::scoped_lock lock( l_ );
p_.swap( r );
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
return std::move( r );
#else
return r;
#endif
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) noexcept
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) noexcept
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) noexcept
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) noexcept
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) noexcept
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) noexcept
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, w );
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) noexcept
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) noexcept
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) noexcept
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) noexcept
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) noexcept
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) noexcept
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
{
return compare_exchange( v, std::move( w ) );
}
#endif
};
} // namespace boost

View File

@@ -20,9 +20,23 @@
#include <boost/config.hpp>
#include <exception>
#ifdef BOOST_BORLANDC
# pragma warn -8026 // Functions with excep. spec. are not expanded inline
#endif
namespace boost
{
// The standard library that comes with Borland C++ 5.5.1, 5.6.4
// defines std::exception and its members as having C calling
// convention (-pc). When the definition of bad_weak_ptr
// is compiled with -ps, the compiler issues an error.
// Hence, the temporary #pragma option -pc below.
#if defined(BOOST_BORLANDC) && BOOST_BORLANDC <= 0x564
# pragma option push -pc
#endif
#if defined(BOOST_CLANG)
// Intel C++ on Mac defines __clang__ but doesn't support the pragma
# pragma clang diagnostic push
@@ -33,7 +47,7 @@ class bad_weak_ptr: public std::exception
{
public:
char const * what() const noexcept override
char const * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
{
return "tr1::bad_weak_ptr";
}
@@ -43,6 +57,14 @@ public:
# pragma clang diagnostic pop
#endif
#if defined(BOOST_BORLANDC) && BOOST_BORLANDC <= 0x564
# pragma option pop
#endif
} // namespace boost
#ifdef BOOST_BORLANDC
# pragma warn .8026 // Functions with excep. spec. are not expanded inline
#endif
#endif // #ifndef BOOST_SMART_PTR_BAD_WEAK_PTR_HPP_INCLUDED

View File

@@ -45,7 +45,6 @@
#include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
#include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/config.hpp>
#if defined( BOOST_AC_DISABLE_THREADS )

View File

@@ -1,52 +0,0 @@
#ifndef BOOST_SMART_PTR_DETAIL_DEPRECATED_MACROS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_DEPRECATED_MACROS_HPP_INCLUDED
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config/pragma_message.hpp>
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
BOOST_PRAGMA_MESSAGE("The macro BOOST_SP_ENABLE_DEBUG_HOOKS has been deprecated in 1.87 and support for it was removed in 1.90.")
#endif
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
BOOST_PRAGMA_MESSAGE("The macro BOOST_SP_USE_STD_ALLOCATOR has been deprecated in 1.87 and support for it was removed in 1.90.")
#endif
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
BOOST_PRAGMA_MESSAGE("The macro BOOST_SP_USE_QUICK_ALLOCATOR has been deprecated in 1.87 and support for it was removed in 1.90.")
#endif
#if defined(BOOST_AC_USE_SPINLOCK)
BOOST_PRAGMA_MESSAGE("The macro BOOST_AC_USE_SPINLOCK has been deprecated in 1.87 and support for it will be removed.")
#endif
#if defined(BOOST_AC_USE_PTHREADS)
BOOST_PRAGMA_MESSAGE("The macro BOOST_AC_USE_PTHREADS has been deprecated in 1.87 and support for it will be removed.")
#endif
#if defined(BOOST_SP_USE_SPINLOCK)
BOOST_PRAGMA_MESSAGE("The macro BOOST_SP_USE_SPINLOCK has been deprecated in 1.87 and support for it will be removed.")
#endif
#if defined(BOOST_SP_USE_PTHREADS)
BOOST_PRAGMA_MESSAGE("The macro BOOST_SP_USE_PTHREADS has been deprecated in 1.87 and support for it will be removed.")
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_DEPRECATED_MACROS_HPP_INCLUDED

View File

@@ -104,10 +104,18 @@ public:
#if defined( BOOST_HAS_PTHREADS )
extern "C" inline void * lw_thread_routine( void * pv )
extern "C" void * lw_thread_routine( void * pv )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#else
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#endif
pt->run();
return 0;
@@ -115,10 +123,18 @@ extern "C" inline void * lw_thread_routine( void * pv )
#else
inline unsigned __stdcall lw_thread_routine( void * pv )
unsigned __stdcall lw_thread_routine( void * pv )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#else
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
#endif
pt->run();
return 0;
@@ -146,8 +162,16 @@ private:
template<class F> int lw_thread_create( lw_thread_t & th, F f )
{
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
#else
std::unique_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
#endif
int r = lw_thread_create_( &th, 0, lw_thread_routine, p.get() );
if( r == 0 )

View File

@@ -42,23 +42,23 @@ private:
public:
constexpr local_counted_base() noexcept: local_use_count_( initial_ )
BOOST_CONSTEXPR local_counted_base() BOOST_SP_NOEXCEPT: local_use_count_( initial_ )
{
}
constexpr local_counted_base( local_counted_base const & ) noexcept: local_use_count_( initial_ )
BOOST_CONSTEXPR local_counted_base( local_counted_base const & ) BOOST_SP_NOEXCEPT: local_use_count_( initial_ )
{
}
virtual ~local_counted_base() /*noexcept*/
virtual ~local_counted_base() /*BOOST_SP_NOEXCEPT*/
{
}
virtual void local_cb_destroy() noexcept = 0;
virtual void local_cb_destroy() BOOST_SP_NOEXCEPT = 0;
virtual boost::detail::shared_count local_cb_get_shared_count() const noexcept = 0;
virtual boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT = 0;
void add_ref() noexcept
void add_ref() BOOST_SP_NOEXCEPT
{
#if !defined(__NVCC__)
#if defined( __has_builtin )
@@ -73,7 +73,7 @@ public:
local_use_count_ = static_cast<count_type>( local_use_count_ + 1 );
}
void release() noexcept
void release() BOOST_SP_NOEXCEPT
{
local_use_count_ = static_cast<count_type>( local_use_count_ - 1 );
@@ -83,7 +83,7 @@ public:
}
}
long local_use_count() const noexcept
long local_use_count() const BOOST_SP_NOEXCEPT
{
return local_use_count_;
}
@@ -101,20 +101,24 @@ private:
public:
explicit local_counted_impl( shared_count const& pn ) noexcept: pn_( pn )
explicit local_counted_impl( shared_count const& pn ) BOOST_SP_NOEXCEPT: pn_( pn )
{
}
explicit local_counted_impl( shared_count && pn ) noexcept: pn_( std::move(pn) )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
explicit local_counted_impl( shared_count && pn ) BOOST_SP_NOEXCEPT: pn_( std::move(pn) )
{
}
void local_cb_destroy() noexcept override
#endif
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
delete this;
}
boost::detail::shared_count local_cb_get_shared_count() const noexcept override
boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return pn_;
}
@@ -126,12 +130,12 @@ public:
shared_count pn_;
void local_cb_destroy() noexcept override
void local_cb_destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
shared_count().swap( pn_ );
}
boost::detail::shared_count local_cb_get_shared_count() const noexcept override
boost::detail::shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return pn_;
}

View File

@@ -38,40 +38,48 @@ public:
{
}
explicit local_sp_deleter( D const& d ) noexcept: d_( d )
explicit local_sp_deleter( D const& d ) BOOST_SP_NOEXCEPT: d_( d )
{
}
explicit local_sp_deleter( D&& d ) noexcept: d_( std::move(d) )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
explicit local_sp_deleter( D&& d ) BOOST_SP_NOEXCEPT: d_( std::move(d) )
{
}
D& deleter() noexcept
#endif
D& deleter() BOOST_SP_NOEXCEPT
{
return d_;
}
template<class Y> void operator()( Y* p ) noexcept
template<class Y> void operator()( Y* p ) BOOST_SP_NOEXCEPT
{
d_( p );
}
void operator()( std::nullptr_t p ) noexcept
#if !defined( BOOST_NO_CXX11_NULLPTR )
void operator()( boost::detail::sp_nullptr_t p ) BOOST_SP_NOEXCEPT
{
d_( p );
}
#endif
};
template<> class local_sp_deleter<void>
{
};
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) noexcept
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT
{
return &p->deleter();
}
inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) noexcept
inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) BOOST_SP_NOEXCEPT
{
return 0;
}

View File

@@ -0,0 +1,64 @@
// This header intentionally has no include guards.
//
// Copyright (c) 2001-2009, 2012 Peter Dimov
//
// 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
#if !defined( BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS ) && !defined( BOOST_NO_CXX11_NULLPTR )\
&& !(defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x5130))
explicit operator bool () const BOOST_SP_NOEXCEPT
{
return px != 0;
}
#elif ( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570) ) || defined(__CINT__)
operator bool () const BOOST_SP_NOEXCEPT
{
return px != 0;
}
#elif defined( _MANAGED )
static void unspecified_bool( this_type*** )
{
}
typedef void (*unspecified_bool_type)( this_type*** );
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: unspecified_bool;
}
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
typedef element_type * (this_type::*unspecified_bool_type)() const;
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: &this_type::get;
}
#else
typedef element_type * this_type::*unspecified_bool_type;
operator unspecified_bool_type() const BOOST_SP_NOEXCEPT
{
return px == 0? 0: &this_type::px;
}
#endif
// operator! is redundant, but some compilers need it
bool operator! () const BOOST_SP_NOEXCEPT
{
return px == 0;
}

View File

@@ -1,63 +1,199 @@
#ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
// Copyright 2003 David Abrahams
// Copyright 2003, 2025 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// MS compatible compilers support #pragma once
#include <boost/config/header_deprecated.hpp>
#include <memory>
#include <cstddef>
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
BOOST_HEADER_DEPRECATED("std::allocator or std::pmr::synchronized_pool_resource")
//
// detail/quick_allocator.hpp
//
// Copyright (c) 2003 David Abrahams
// Copyright (c) 2003 Peter Dimov
//
// 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)
//
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/lightweight_mutex.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <new> // ::operator new, ::operator delete
#include <cstddef> // std::size_t
namespace boost
{
namespace detail
{
template<class T> struct quick_allocator
template<unsigned size, unsigned align_> union freeblock
{
static void* alloc()
typedef typename boost::type_with_alignment<align_>::type aligner_type;
aligner_type aligner;
char bytes[size];
freeblock * next;
};
template<unsigned size, unsigned align_> struct allocator_impl
{
typedef freeblock<size, align_> block;
// It may seem odd to use such small pages.
//
// However, on a typical Windows implementation that uses
// the OS allocator, "normal size" pages interact with the
// "ordinary" operator new, slowing it down dramatically.
//
// 512 byte pages are handled by the small object allocator,
// and don't interfere with ::new.
//
// The other alternative is to use much bigger pages (1M.)
//
// It is surprisingly easy to hit pathological behavior by
// varying the page size. g++ 2.96 on Red Hat Linux 7.2,
// for example, passionately dislikes 496. 512 seems OK.
#if defined(BOOST_QA_PAGE_SIZE)
enum { items_per_page = BOOST_QA_PAGE_SIZE / size };
#else
enum { items_per_page = 512 / size }; // 1048560 / size
#endif
#ifdef BOOST_HAS_THREADS
static lightweight_mutex & mutex()
{
return std::allocator<T>().allocate( 1 );
static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm;
static lightweight_mutex * pm = new( &fbm ) lightweight_mutex;
return *pm;
}
static void* alloc( std::size_t n )
static lightweight_mutex * mutex_init;
#endif
static block * free;
static block * page;
static unsigned last;
static inline void * alloc()
{
if( n != sizeof(T) ) // class-specific delete called for a derived object
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
return ::operator new( n );
free = x->next;
return x;
}
else
{
return alloc();
if(last == items_per_page)
{
// "Listen to me carefully: there is no memory leak"
// -- Scott Meyers, Eff C++ 2nd Ed Item 10
page = ::new block[items_per_page];
last = 0;
}
return &page[last++];
}
}
static void dealloc( void* p )
static inline void * alloc(std::size_t n)
{
if( p != 0 ) // 18.4.1.1/13
if(n != size) // class-specific new called for a derived object
{
std::allocator<T>().deallocate( static_cast<T*>( p ), 1 );
}
}
static void dealloc( void* p, std::size_t n )
{
if( n != sizeof(T) ) // class-specific delete called for a derived object
{
::operator delete( p );
return ::operator new(n);
}
else
{
dealloc( p );
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
if(block * x = free)
{
free = x->next;
return x;
}
else
{
if(last == items_per_page)
{
page = ::new block[items_per_page];
last = 0;
}
return &page[last++];
}
}
}
static inline void dealloc(void * pv)
{
if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
free = pb;
}
}
static inline void dealloc(void * pv, std::size_t n)
{
if(n != size) // class-specific delete called for a derived object
{
::operator delete(pv);
}
else if(pv != 0) // 18.4.1.1/13
{
#ifdef BOOST_HAS_THREADS
lightweight_mutex::scoped_lock lock( mutex() );
#endif
block * pb = static_cast<block *>(pv);
pb->next = free;
free = pb;
}
}
};
#ifdef BOOST_HAS_THREADS
template<unsigned size, unsigned align_>
lightweight_mutex * allocator_impl<size, align_>::mutex_init = &allocator_impl<size, align_>::mutex();
#endif
template<unsigned size, unsigned align_>
freeblock<size, align_> * allocator_impl<size, align_>::free = 0;
template<unsigned size, unsigned align_>
freeblock<size, align_> * allocator_impl<size, align_>::page = 0;
template<unsigned size, unsigned align_>
unsigned allocator_impl<size, align_>::last = allocator_impl<size, align_>::items_per_page;
template<class T>
struct quick_allocator: public allocator_impl< sizeof(T), boost::alignment_of<T>::value >
{
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED

View File

@@ -18,11 +18,15 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(__BORLANDC__) && !defined(__clang__)
# pragma warn -8027 // Functions containing try are not expanded inline
#endif
#include <boost/smart_ptr/bad_weak_ptr.hpp>
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/throw_exception.hpp>
#include <boost/core/addressof.hpp>
@@ -55,6 +59,13 @@ template< class T, class D > class unique_ptr;
namespace detail
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int const shared_count_id = 0x2C35F101;
int const weak_count_id = 0x298C38A4;
#endif
struct sp_nothrow_tag {};
template< class D > struct sp_inplace_tag
@@ -89,7 +100,7 @@ template< class D > struct sp_convert_reference< D& >
typedef sp_reference_wrapper< D > type;
};
template<class T> std::size_t sp_hash_pointer( T* p ) noexcept
template<class T> std::size_t sp_hash_pointer( T* p ) BOOST_NOEXCEPT
{
boost::uintptr_t v = reinterpret_cast<boost::uintptr_t>( p );
@@ -105,19 +116,32 @@ private:
sp_counted_base * pi_;
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int id_;
#endif
friend class weak_count;
public:
constexpr shared_count() noexcept: pi_(0)
BOOST_CONSTEXPR shared_count() BOOST_SP_NOEXCEPT: pi_(0)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
}
constexpr explicit shared_count( sp_counted_base * pi ) noexcept: pi_( pi )
BOOST_CONSTEXPR explicit shared_count( sp_counted_base * pi ) BOOST_SP_NOEXCEPT: pi_( pi )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
}
template<class Y> explicit shared_count( Y * p ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifndef BOOST_NO_EXCEPTIONS
@@ -144,8 +168,18 @@ public:
#endif
}
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
template<class Y, class D> shared_count( Y * p, D d ): pi_(0)
#else
template<class P, class D> shared_count( P p, D d ): pi_(0)
#endif
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, <= 1200 )
typedef Y* P;
#endif
#ifndef BOOST_NO_EXCEPTIONS
try
@@ -171,7 +205,12 @@ public:
#endif
}
#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template< class P, class D > shared_count( P p, sp_inplace_tag<D> ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifndef BOOST_NO_EXCEPTIONS
@@ -198,12 +237,25 @@ public:
#endif // #ifndef BOOST_NO_EXCEPTIONS
}
#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template<class P, class D, class A> shared_count( P p, D d, A a ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef sp_counted_impl_pda<P, D, A> impl_type;
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2;
#else
typedef typename A::template rebind< impl_type >::other A2;
#endif
A2 a2( a );
#ifndef BOOST_NO_EXCEPTIONS
@@ -242,12 +294,25 @@ public:
#endif
}
#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
template< class P, class D, class A > shared_count( P p, sp_inplace_tag< D >, A a ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef sp_counted_impl_pda< P, D, A > impl_type;
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc< impl_type > A2;
#else
typedef typename A::template rebind< impl_type >::other A2;
#endif
A2 a2( a );
#ifndef BOOST_NO_EXCEPTIONS
@@ -286,12 +351,17 @@ public:
#endif // #ifndef BOOST_NO_EXCEPTIONS
}
#endif // !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
#ifndef BOOST_NO_AUTO_PTR
// auto_ptr<Y> is special cased to provide the strong guarantee
template<class Y>
explicit shared_count( std::auto_ptr<Y> & r ): pi_( new sp_counted_impl_p<Y>( r.get() ) )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
#ifdef BOOST_NO_EXCEPTIONS
@@ -307,8 +377,13 @@ public:
#endif
#if !defined( BOOST_NO_CXX11_SMART_PTR )
template<class Y, class D>
explicit shared_count( std::unique_ptr<Y, D> & r ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef typename sp_convert_reference<D>::type D2;
@@ -327,8 +402,13 @@ public:
r.release();
}
#endif
template<class Y, class D>
explicit shared_count( boost::movelib::unique_ptr<Y, D> & r ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
typedef typename sp_convert_reference<D>::type D2;
@@ -347,25 +427,38 @@ public:
r.release();
}
~shared_count() /*noexcept*/
~shared_count() /*BOOST_SP_NOEXCEPT*/
{
if( pi_ != 0 ) pi_->release();
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
id_ = 0;
#endif
}
shared_count(shared_count const & r) noexcept: pi_(r.pi_)
shared_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ != 0 ) pi_->add_ref_copy();
}
shared_count(shared_count && r) noexcept: pi_(r.pi_)
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
shared_count(shared_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
r.pi_ = 0;
}
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
shared_count( weak_count const & r, sp_nothrow_tag ) noexcept; // constructs an empty *this when r.use_count() == 0
#endif
shared_count & operator= (shared_count const & r) noexcept
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT; // constructs an empty *this when r.use_count() == 0
shared_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
@@ -379,58 +472,58 @@ public:
return *this;
}
void swap(shared_count & r) noexcept
void swap(shared_count & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
r.pi_ = pi_;
pi_ = tmp;
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return pi_ != 0? pi_->use_count(): 0;
}
bool unique() const noexcept
bool unique() const BOOST_SP_NOEXCEPT
{
return use_count() == 1;
}
bool empty() const noexcept
bool empty() const BOOST_SP_NOEXCEPT
{
return pi_ == 0;
}
bool operator==( shared_count const & r ) const noexcept
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator==( weak_count const & r ) const noexcept;
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT;
bool operator<( shared_count const & r ) const noexcept
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
bool operator<( weak_count const & r ) const noexcept;
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT;
void * get_deleter( sp_typeinfo_ const & ti ) const noexcept
void * get_deleter( sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_deleter( ti ): 0;
}
void * get_local_deleter( sp_typeinfo_ const & ti ) const noexcept
void * get_local_deleter( sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_local_deleter( ti ): 0;
}
void * get_untyped_deleter() const noexcept
void * get_untyped_deleter() const BOOST_SP_NOEXCEPT
{
return pi_? pi_->get_untyped_deleter(): 0;
}
std::size_t hash_value() const noexcept
std::size_t hash_value() const BOOST_SP_NOEXCEPT
{
return sp_hash_pointer( pi_ );
}
@@ -443,37 +536,60 @@ private:
sp_counted_base * pi_;
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
int id_;
#endif
friend class shared_count;
public:
constexpr weak_count() noexcept: pi_(0)
BOOST_CONSTEXPR weak_count() BOOST_SP_NOEXCEPT: pi_(0)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
}
weak_count(shared_count const & r) noexcept: pi_(r.pi_)
weak_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
if(pi_ != 0) pi_->weak_add_ref();
}
weak_count(weak_count const & r) noexcept: pi_(r.pi_)
weak_count(weak_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
if(pi_ != 0) pi_->weak_add_ref();
}
// Move support
weak_count(weak_count && r) noexcept: pi_(r.pi_)
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
weak_count(weak_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(weak_count_id)
#endif
{
r.pi_ = 0;
}
~weak_count() /*noexcept*/
#endif
~weak_count() /*BOOST_SP_NOEXCEPT*/
{
if(pi_ != 0) pi_->weak_release();
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
id_ = 0;
#endif
}
weak_count & operator= (shared_count const & r) noexcept
weak_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
@@ -487,7 +603,7 @@ public:
return *this;
}
weak_count & operator= (weak_count const & r) noexcept
weak_count & operator= (weak_count const & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
@@ -501,50 +617,53 @@ public:
return *this;
}
void swap(weak_count & r) noexcept
void swap(weak_count & r) BOOST_SP_NOEXCEPT
{
sp_counted_base * tmp = r.pi_;
r.pi_ = pi_;
pi_ = tmp;
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return pi_ != 0? pi_->use_count(): 0;
}
bool empty() const noexcept
bool empty() const BOOST_SP_NOEXCEPT
{
return pi_ == 0;
}
bool operator==( weak_count const & r ) const noexcept
bool operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator==( shared_count const & r ) const noexcept
bool operator==( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
bool operator<( weak_count const & r ) const noexcept
bool operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
bool operator<( shared_count const & r ) const noexcept
bool operator<( shared_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
std::size_t hash_value() const noexcept
std::size_t hash_value() const BOOST_SP_NOEXCEPT
{
return sp_hash_pointer( pi_ );
}
};
inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ == 0 || !pi_->add_ref_lock() )
{
@@ -552,7 +671,10 @@ inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ )
}
}
inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) noexcept: pi_( r.pi_ )
inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT: pi_( r.pi_ )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
if( pi_ != 0 && !pi_->add_ref_lock() )
{
@@ -560,12 +682,12 @@ inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) noexce
}
}
inline bool shared_count::operator==( weak_count const & r ) const noexcept
inline bool shared_count::operator==( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return pi_ == r.pi_;
}
inline bool shared_count::operator<( weak_count const & r ) const noexcept
inline bool shared_count::operator<( weak_count const & r ) const BOOST_SP_NOEXCEPT
{
return std::less<sp_counted_base *>()( pi_, r.pi_ );
}
@@ -578,4 +700,8 @@ inline bool shared_count::operator<( weak_count const & r ) const noexcept
#pragma GCC diagnostic pop
#endif
#if defined(__BORLANDC__) && !defined(__clang__)
# pragma warn .8027 // Functions containing try are not expanded inline
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SHARED_COUNT_HPP_INCLUDED

View File

@@ -18,6 +18,20 @@
#include <boost/config.hpp>
#include <cstddef>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_BORLANDC ) && ( BOOST_BORLANDC < 0x630 )
# define BOOST_SP_NO_SP_CONVERTIBLE
#endif
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
namespace boost
{
@@ -73,4 +87,6 @@ template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_i
} // namespace boost
#endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED

View File

@@ -19,7 +19,6 @@
#include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
#include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/config.hpp>
#if defined( BOOST_SP_DISABLE_THREADS )

View File

@@ -137,7 +137,7 @@ public:
long use_count() const // nothrow
{
return static_cast<long>( atomic_load( &use_count_ ) );
return atomic_load( &use_count_ );
}
};

View File

@@ -19,6 +19,7 @@
//
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
@@ -47,43 +48,43 @@ private:
public:
sp_counted_base() noexcept: use_count_( 1 ), weak_count_( 1 )
sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() /*noexcept*/
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() noexcept = 0; // nothrow
virtual void dispose() BOOST_SP_NOEXCEPT = 0; // nothrow
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() noexcept // nothrow
virtual void destroy() BOOST_SP_NOEXCEPT // nothrow
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) noexcept = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) noexcept = 0;
virtual void * get_untyped_deleter() noexcept = 0;
virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
void add_ref_copy() noexcept
void add_ref_copy() BOOST_SP_NOEXCEPT
{
++use_count_;
}
bool add_ref_lock() noexcept // true on success
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
{
if( use_count_ == 0 ) return false;
++use_count_;
return true;
}
void release() noexcept
void release() BOOST_SP_NOEXCEPT
{
if( --use_count_ == 0 )
{
@@ -92,12 +93,12 @@ public:
}
}
void weak_add_ref() noexcept
void weak_add_ref() BOOST_SP_NOEXCEPT
{
++weak_count_;
}
void weak_release() noexcept
void weak_release() BOOST_SP_NOEXCEPT
{
if( --weak_count_ == 0 )
{
@@ -105,7 +106,7 @@ public:
}
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return use_count_;
}

View File

@@ -16,6 +16,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/smart_ptr/detail/sp_typeinfo_.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config.hpp>
#include <atomic>
#include <cstdint>
@@ -33,17 +34,17 @@ namespace boost
namespace detail
{
inline void atomic_increment( std::atomic_int_least32_t * pw ) noexcept
inline void atomic_increment( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
{
pw->fetch_add( 1, std::memory_order_relaxed );
}
inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw ) noexcept
inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
{
return pw->fetch_sub( 1, std::memory_order_acq_rel );
}
inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw ) noexcept
inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
{
// long r = *pw;
// if( r != 0 ) ++*pw;
@@ -77,41 +78,41 @@ private:
public:
sp_counted_base() noexcept: use_count_( 1 ), weak_count_( 1 )
sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
{
}
virtual ~sp_counted_base() /*noexcept*/
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
{
}
// dispose() is called when use_count_ drops to zero, to release
// the resources managed by *this.
virtual void dispose() noexcept = 0;
virtual void dispose() BOOST_SP_NOEXCEPT = 0;
// destroy() is called when weak_count_ drops to zero.
virtual void destroy() noexcept
virtual void destroy() BOOST_SP_NOEXCEPT
{
delete this;
}
virtual void * get_deleter( sp_typeinfo_ const & ti ) noexcept = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) noexcept = 0;
virtual void * get_untyped_deleter() noexcept = 0;
virtual void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT = 0;
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
void add_ref_copy() noexcept
void add_ref_copy() BOOST_SP_NOEXCEPT
{
atomic_increment( &use_count_ );
}
bool add_ref_lock() noexcept // true on success
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
{
return atomic_conditional_increment( &use_count_ ) != 0;
}
void release() noexcept
void release() BOOST_SP_NOEXCEPT
{
if( atomic_decrement( &use_count_ ) == 1 )
{
@@ -120,12 +121,12 @@ public:
}
}
void weak_add_ref() noexcept
void weak_add_ref() BOOST_SP_NOEXCEPT
{
atomic_increment( &weak_count_ );
}
void weak_release() noexcept
void weak_release() BOOST_SP_NOEXCEPT
{
if( atomic_decrement( &weak_count_ ) == 1 )
{
@@ -133,7 +134,7 @@ public:
}
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return use_count_.load( std::memory_order_acquire );
}

View File

@@ -90,7 +90,18 @@ public:
long tmp = static_cast< long const volatile& >( use_count_ );
if( tmp == 0 ) return false;
#if defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, == 1200 )
// work around a code generation bug
long tmp2 = tmp + 1;
if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp2, tmp ) == tmp2 - 1 ) return true;
#else
if( BOOST_SP_INTERLOCKED_COMPARE_EXCHANGE( &use_count_, tmp + 1, tmp ) == tmp ) return true;
#endif
}
}

View File

@@ -18,18 +18,33 @@
// http://www.boost.org/LICENSE_1_0.txt)
//
#if defined(BOOST_SP_USE_STD_ALLOCATOR) && defined(BOOST_SP_USE_QUICK_ALLOCATOR)
# error BOOST_SP_USE_STD_ALLOCATOR and BOOST_SP_USE_QUICK_ALLOCATOR are incompatible.
#endif
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/core/addressof.hpp>
#include <boost/config.hpp>
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
#include <boost/smart_ptr/detail/quick_allocator.hpp>
#endif
#include <memory> // std::allocator, std::allocator_traits
#include <cstddef> // std::size_t
namespace boost
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
void sp_scalar_constructor_hook( void * px, std::size_t size, void * pn );
void sp_scalar_destructor_hook( void * px, std::size_t size, void * pn );
#endif
namespace detail
{
@@ -37,12 +52,12 @@ namespace detail
template<class D> class local_sp_deleter;
template<class D> D * get_local_deleter( D * /*p*/ ) noexcept
template<class D> D * get_local_deleter( D * /*p*/ ) BOOST_SP_NOEXCEPT
{
return 0;
}
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) noexcept;
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT;
//
@@ -61,29 +76,70 @@ public:
explicit sp_counted_impl_p( X * px ): px_( px )
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_constructor_hook( px, sizeof(X), this );
#endif
}
void dispose() noexcept override
void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
#endif
boost::checked_delete( px_ );
}
void * get_deleter( sp_typeinfo_ const & ) noexcept override
void * get_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return 0;
}
void * get_local_deleter( sp_typeinfo_ const & ) noexcept override
void * get_local_deleter( sp_typeinfo_ const & ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return 0;
}
void * get_untyped_deleter() noexcept override
void * get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return 0;
}
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
void * operator new( std::size_t )
{
return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
}
void operator delete( void * p )
{
std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
}
#endif
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
void * operator new( std::size_t )
{
return quick_allocator<this_type>::alloc();
}
void operator delete( void * p )
{
quick_allocator<this_type>::dealloc( p );
}
#endif
};
//
// Borland's Codeguard trips up over the -Vx- option here:
//
#ifdef __CODEGUARD__
# pragma option push -Vx-
#endif
template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public sp_counted_base
{
private:
@@ -100,33 +156,71 @@ public:
// pre: d(p) must not throw
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
sp_counted_impl_pd( P p, D & d ): ptr( p ), del( static_cast< D&& >( d ) )
{
}
#else
sp_counted_impl_pd( P p, D & d ): ptr( p ), del( d )
{
}
#endif
sp_counted_impl_pd( P p ): ptr( p ), del()
{
}
void dispose() noexcept override
void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
del( ptr );
}
void * get_deleter( sp_typeinfo_ const & ti ) noexcept override
void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return ti == BOOST_SP_TYPEID_(D)? &reinterpret_cast<char&>( del ): 0;
}
void * get_local_deleter( sp_typeinfo_ const & ti ) noexcept override
void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return ti == BOOST_SP_TYPEID_(D)? boost::detail::get_local_deleter( boost::addressof( del ) ): 0;
}
void * get_untyped_deleter() noexcept override
void * get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return &reinterpret_cast<char&>( del );
}
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
void * operator new( std::size_t )
{
return std::allocator<this_type>().allocate( 1, static_cast<this_type *>(0) );
}
void operator delete( void * p )
{
std::allocator<this_type>().deallocate( static_cast<this_type *>(p), 1 );
}
#endif
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
void * operator new( std::size_t )
{
return quick_allocator<this_type>::alloc();
}
void operator delete( void * p )
{
quick_allocator<this_type>::dealloc( p );
}
#endif
};
template<class P, class D, class A> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pda: public sp_counted_base
@@ -146,23 +240,41 @@ public:
// pre: d( p ) must not throw
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( static_cast< D&& >( d ) ), a_( a )
{
}
#else
sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( d ), a_( a )
{
}
#endif
sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a )
{
}
void dispose() noexcept override
void dispose() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
d_( p_ );
}
void destroy() noexcept override
void destroy() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc< this_type > A2;
#else
typedef typename A::template rebind< this_type >::other A2;
#endif
A2 a2( a_ );
this->~this_type();
@@ -170,22 +282,26 @@ public:
a2.deallocate( this, 1 );
}
void * get_deleter( sp_typeinfo_ const & ti ) noexcept override
void * get_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return ti == BOOST_SP_TYPEID_( D )? &reinterpret_cast<char&>( d_ ): 0;
}
void * get_local_deleter( sp_typeinfo_ const & ti ) noexcept override
void * get_local_deleter( sp_typeinfo_ const & ti ) BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return ti == BOOST_SP_TYPEID_( D )? boost::detail::get_local_deleter( boost::addressof( d_ ) ): 0;
}
void * get_untyped_deleter() noexcept override
void * get_untyped_deleter() BOOST_SP_NOEXCEPT BOOST_OVERRIDE
{
return &reinterpret_cast<char&>( d_ );
}
};
#ifdef __CODEGUARD__
# pragma option pop
#endif
} // namespace detail
} // namespace boost

View File

@@ -1,37 +0,0 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_CXX20_CONSTEXPR_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_CXX20_CONSTEXPR_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
// detail/sp_noexcept.hpp
//
// Copyright 2025 Mathias Stearn
//
// 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
// This macro is used to mark functions as constexpr if the compiler supports
// constexpr destructors. Since you can't have a constexpr smart pointer object,
// everything except null constructors are guided behind this macro. Because
// this also guards a use of dynamic_cast, we need to check for its availability
// as well. It isn't worth splitting out since all known compilers that support
// constexpr dynamic_cast also support constexpr destructors.
//
// WARNING: This does not check for changing active member of a union in
// constant expressions which is allowed in C++20. If that is needed, we
// need to raise the checked version to 202002L.
#if defined(__cpp_constexpr_dynamic_alloc) && __cpp_constexpr_dynamic_alloc >= 201907L \
&& defined(__cpp_constexpr) && __cpp_constexpr >= 201907L
#define BOOST_SP_CXX20_CONSTEXPR constexpr
#else
#define BOOST_SP_CXX20_CONSTEXPR
#define BOOST_SP_NO_CXX20_CONSTEXPR
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CXX20_CONSTEXPR_HPP_INCLUDED

View File

@@ -0,0 +1,52 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_forward.hpp
//
// Copyright 2008,2012 Peter Dimov
//
// 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
#include <boost/config.hpp>
namespace boost
{
namespace detail
{
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
#if defined( BOOST_GCC ) && __GNUC__ * 100 + __GNUC_MINOR__ <= 404
// GCC 4.4 supports an outdated version of rvalue references and creates a copy of the forwarded object.
// This results in warnings 'returning reference to temporary'. Therefore we use a special version similar to std::forward.
template< class T > T&& sp_forward( T && t ) BOOST_NOEXCEPT
{
return t;
}
#else
template< class T > T&& sp_forward( T & t ) BOOST_NOEXCEPT
{
return static_cast< T&& >( t );
}
#endif
#endif
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_FORWARD_HPP_INCLUDED

View File

@@ -17,11 +17,8 @@
// Defines the BOOST_SP_HAS_GCC_INTRINSICS macro if the __atomic_*
// intrinsics are available.
// Libraries (e.g. Kokkos) sometimes define the __ATOMIC_RELAXED macros,
// leading to errors under MSVC (https://github.com/boostorg/smart_ptr/pull/112)
#if defined( __ATOMIC_RELAXED ) && defined( __ATOMIC_ACQUIRE ) && defined( __ATOMIC_RELEASE ) && defined( __ATOMIC_ACQ_REL ) \
&& !( defined(_MSC_VER) && !defined(__clang__) )
#if defined( __ATOMIC_RELAXED ) && defined( __ATOMIC_ACQUIRE ) && defined( __ATOMIC_RELEASE ) && defined( __ATOMIC_ACQ_REL )
# define BOOST_SP_HAS_GCC_INTRINSICS

View File

@@ -15,16 +15,25 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
// BOOST_SP_NOEXCEPT (obsolete, only retained for compatibility)
// BOOST_SP_NOEXCEPT
#define BOOST_SP_NOEXCEPT noexcept
#if defined( BOOST_MSVC ) && BOOST_MSVC >= 1700 && BOOST_MSVC < 1900
// BOOST_SP_NOEXCEPT_WITH_ASSERT (noexcept, unless a user assertion handler is present)
# define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW
#else
# define BOOST_SP_NOEXCEPT BOOST_NOEXCEPT
#endif
// BOOST_SP_NOEXCEPT_WITH_ASSERT
#if defined(BOOST_DISABLE_ASSERTS) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && defined(NDEBUG) )
# define BOOST_SP_NOEXCEPT_WITH_ASSERT noexcept
# define BOOST_SP_NOEXCEPT_WITH_ASSERT BOOST_SP_NOEXCEPT
#elif defined(BOOST_ENABLE_ASSERT_HANDLER) || ( defined(BOOST_ENABLE_ASSERT_DEBUG_HANDLER) && !defined(NDEBUG) )
@@ -32,7 +41,7 @@
#else
# define BOOST_SP_NOEXCEPT_WITH_ASSERT noexcept
# define BOOST_SP_NOEXCEPT_WITH_ASSERT BOOST_SP_NOEXCEPT
#endif

View File

@@ -0,0 +1,45 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// detail/sp_nullptr_t.hpp
//
// Copyright 2013 Peter Dimov
//
// 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
#include <boost/config.hpp>
#include <cstddef>
#if !defined( BOOST_NO_CXX11_NULLPTR )
namespace boost
{
namespace detail
{
#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) )
typedef decltype(nullptr) sp_nullptr_t;
#else
typedef std::nullptr_t sp_nullptr_t;
#endif
} // namespace detail
} // namespace boost
#endif // !defined( BOOST_NO_CXX11_NULLPTR )
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_NULLPTR_T_HPP_INCLUDED

View File

@@ -1,23 +1,51 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/smart_ptr/detail/sp_thread_pause.hpp
//
// inline void bost::detail::sp_thread_pause();
//
// Emits a "pause" instruction.
//
// Copyright 2008, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/yield_primitives.hpp>
#include <boost/config/header_deprecated.hpp>
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) && !defined(__c2__)
BOOST_HEADER_DEPRECATED( "<boost/core/yield_primitives.hpp>" )
extern "C" void _mm_pause();
#define BOOST_SP_PAUSE _mm_pause();
#elif defined(__GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
#define BOOST_SP_PAUSE __asm__ __volatile__( "rep; nop" : : : "memory" );
#else
#define BOOST_SP_PAUSE
#endif
namespace boost
{
namespace detail
{
using boost::core::sp_thread_pause;
inline void sp_thread_pause()
{
BOOST_SP_PAUSE
}
} // namespace detail
} // namespace boost
#undef BOOST_SP_PAUSE
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_PAUSE_HPP_INCLUDED

View File

@@ -1,23 +1,104 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/smart_ptr/detail/sp_thread_sleep.hpp
//
// inline void bost::detail::sp_thread_sleep();
//
// Cease execution for a while to yield to other threads,
// as if by calling nanosleep() with an appropriate interval.
//
// Copyright 2008, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/yield_primitives.hpp>
#include <boost/config/header_deprecated.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
BOOST_HEADER_DEPRECATED( "<boost/core/yield_primitives.hpp>" )
#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using Sleep(1) in sp_thread_sleep")
#endif
#include <boost/smart_ptr/detail/sp_win32_sleep.hpp>
namespace boost
{
namespace detail
{
using boost::core::sp_thread_sleep;
inline void sp_thread_sleep()
{
Sleep( 1 );
}
} // namespace detail
} // namespace boost
#elif defined(BOOST_HAS_NANOSLEEP)
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using nanosleep() in sp_thread_sleep")
#endif
#include <time.h>
namespace boost
{
namespace detail
{
inline void sp_thread_sleep()
{
// g++ -Wextra warns on {} or {0}
struct timespec rqtp = { 0, 0 };
// POSIX says that timespec has tv_sec and tv_nsec
// But it doesn't guarantee order or placement
rqtp.tv_sec = 0;
rqtp.tv_nsec = 1000;
nanosleep( &rqtp, 0 );
}
} // namespace detail
} // namespace boost
#else
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using sp_thread_yield() in sp_thread_sleep")
#endif
#include <boost/smart_ptr/detail/sp_thread_yield.hpp>
namespace boost
{
namespace detail
{
inline void sp_thread_sleep()
{
sp_thread_yield();
}
} // namespace detail
} // namespace boost
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_SLEEP_HPP_INCLUDED

View File

@@ -1,23 +1,100 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED
// Copyright 2023 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/smart_ptr/detail/sp_thread_yield.hpp
//
// inline void bost::detail::sp_thread_yield();
//
// Gives up the remainder of the time slice,
// as if by calling sched_yield().
//
// Copyright 2008, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/yield_primitives.hpp>
#include <boost/config/header_deprecated.hpp>
#include <boost/config.hpp>
#include <boost/config/pragma_message.hpp>
BOOST_HEADER_DEPRECATED( "<boost/core/yield_primitives.hpp>" )
#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || defined( __CYGWIN__ )
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using Sleep(0) in sp_thread_yield")
#endif
#include <boost/smart_ptr/detail/sp_win32_sleep.hpp>
namespace boost
{
namespace detail
{
using boost::core::sp_thread_yield;
inline void sp_thread_yield()
{
Sleep( 0 );
}
} // namespace detail
} // namespace boost
#elif defined(BOOST_HAS_SCHED_YIELD)
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using sched_yield() in sp_thread_yield")
#endif
#ifndef _AIX
# include <sched.h>
#else
// AIX's sched.h defines ::var which sometimes conflicts with Lambda's var
extern "C" int sched_yield(void);
#endif
namespace boost
{
namespace detail
{
inline void sp_thread_yield()
{
sched_yield();
}
} // namespace detail
} // namespace boost
#else
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
BOOST_PRAGMA_MESSAGE("Using sp_thread_pause() in sp_thread_yield")
#endif
#include <boost/smart_ptr/detail/sp_thread_pause.hpp>
namespace boost
{
namespace detail
{
inline void sp_thread_yield()
{
sp_thread_pause();
}
} // namespace detail
} // namespace boost
#endif
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_THREAD_YIELD_HPP_INCLUDED

View File

@@ -1,55 +0,0 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED
// Copyright 2024 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <type_traits>
namespace boost
{
namespace detail
{
// std::is_bounded_array (C++20)
template<class T> struct sp_is_bounded_array: std::false_type
{
};
template<class T, std::size_t N> struct sp_is_bounded_array< T[N] >: std::true_type
{
};
// std::is_unbounded_array (C++20)
template<class T> struct sp_is_unbounded_array: std::false_type
{
};
template<class T> struct sp_is_unbounded_array< T[] >: std::true_type
{
};
// std::type_identity (C++20)
template<class T> struct sp_type_identity
{
typedef T type;
};
// boost::type_with_alignment
template<std::size_t A> struct sp_type_with_alignment
{
struct alignas(A) type
{
unsigned char padding[ A ];
};
};
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_TYPE_TRAITS_HPP_INCLUDED

View File

@@ -0,0 +1,49 @@
#ifndef BOOST_SMART_PTR_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED
#define BOOST_SMART_PTR_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED
// MS compatible compilers support #pragma once
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
// boost/smart_ptr/detail/sp_win32_sleep.hpp
//
// Declares the Win32 Sleep() function.
//
// Copyright 2008, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0
// https://www.boost.org/LICENSE_1_0.txt
#if defined( BOOST_USE_WINDOWS_H )
# include <windows.h>
#endif
namespace boost
{
namespace detail
{
#if !defined( BOOST_USE_WINDOWS_H )
#if defined(__clang__) && defined(__x86_64__)
// clang x64 warns that __stdcall is ignored
# define BOOST_SP_STDCALL
#else
# define BOOST_SP_STDCALL __stdcall
#endif
#if defined(__LP64__) // Cygwin 64
extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned int ms );
#else
extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned long ms );
#endif
#undef BOOST_SP_STDCALL
#endif // !defined( BOOST_USE_WINDOWS_H )
} // namespace detail
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_WIN32_SLEEP_HPP_INCLUDED

View File

@@ -30,7 +30,6 @@
#include <boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp>
#include <boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/config.hpp>
#if defined( BOOST_SP_USE_STD_ATOMIC )

View File

@@ -30,16 +30,7 @@ class spinlock
{
public:
// `bool` alignment is required for Apple PPC32
// https://github.com/boostorg/smart_ptr/issues/105
// https://github.com/PurpleI2P/i2pd/issues/1726
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107590
union
{
unsigned char v_;
bool align_;
};
unsigned char v_;
public:
@@ -89,6 +80,6 @@ public:
} // namespace detail
} // namespace boost
#define BOOST_DETAIL_SPINLOCK_INIT {{0}}
#define BOOST_DETAIL_SPINLOCK_INIT {0}
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_GCC_ATOMIC_HPP_INCLUDED

View File

@@ -16,6 +16,7 @@
//
#include <boost/smart_ptr/detail/yield_k.hpp>
#include <boost/config.hpp>
#include <atomic>
#if defined(BOOST_SP_REPORT_IMPLEMENTATION)
@@ -39,12 +40,12 @@ public:
public:
bool try_lock() noexcept
bool try_lock() BOOST_NOEXCEPT
{
return !v_.test_and_set( std::memory_order_acquire );
}
void lock() noexcept
void lock() BOOST_NOEXCEPT
{
for( unsigned k = 0; !try_lock(); ++k )
{
@@ -52,7 +53,7 @@ public:
}
}
void unlock() noexcept
void unlock() BOOST_NOEXCEPT
{
v_ .clear( std::memory_order_release );
}
@@ -70,12 +71,12 @@ public:
public:
explicit scoped_lock( spinlock & sp ) noexcept: sp_( sp )
explicit scoped_lock( spinlock & sp ) BOOST_NOEXCEPT: sp_( sp )
{
sp.lock();
}
~scoped_lock() /*noexcept*/
~scoped_lock() /*BOOST_NOEXCEPT*/
{
sp_.unlock();
}

View File

@@ -19,7 +19,9 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/core/yield_primitives.hpp>
#include <boost/smart_ptr/detail/sp_thread_pause.hpp>
#include <boost/smart_ptr/detail/sp_thread_sleep.hpp>
#include <boost/config.hpp>
namespace boost
{
@@ -32,13 +34,13 @@ inline void yield( unsigned k )
// Experiments on Windows and Fedora 32 show that a single pause,
// followed by an immediate sp_thread_sleep(), is best.
if( k & 1 )
if( k == 0 )
{
boost::core::sp_thread_sleep();
sp_thread_pause();
}
else
{
boost::core::sp_thread_pause();
sp_thread_sleep();
}
}

View File

@@ -12,6 +12,7 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
namespace boost
{
@@ -30,7 +31,7 @@ template<class T> shared_ptr<T> shared_from( T * p )
return shared_ptr<T>( p->enable_shared_from_this<enable_shared_from>::shared_from_this(), p );
}
template<class T> weak_ptr<T> weak_from( T * p ) noexcept
template<class T> weak_ptr<T> weak_from( T * p ) BOOST_SP_NOEXCEPT
{
return weak_ptr<T>( p->enable_shared_from_this<enable_shared_from>::weak_from_this(), p );
}

View File

@@ -71,12 +71,15 @@ private:
}
}
#ifdef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
public:
#else
private:
template<class Y> friend class shared_ptr;
template<typename T> friend boost::shared_ptr<T> shared_from_raw(T *);
template<typename T> friend boost::weak_ptr<T> weak_from_raw(T *);
template< class X, class Y > friend inline void detail::sp_enable_shared_from_this( boost::shared_ptr<X> * ppx, Y const * py, boost::enable_shared_from_raw const * pe );
#endif
shared_ptr<void const volatile> shared_from_this() const
{

View File

@@ -15,7 +15,9 @@
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
namespace boost
{
@@ -24,20 +26,20 @@ template<class T> class enable_shared_from_this
{
protected:
constexpr enable_shared_from_this() noexcept
BOOST_CONSTEXPR enable_shared_from_this() BOOST_SP_NOEXCEPT
{
}
constexpr enable_shared_from_this(enable_shared_from_this const &) noexcept
BOOST_CONSTEXPR enable_shared_from_this(enable_shared_from_this const &) BOOST_SP_NOEXCEPT
{
}
enable_shared_from_this & operator=(enable_shared_from_this const &) noexcept
enable_shared_from_this & operator=(enable_shared_from_this const &) BOOST_SP_NOEXCEPT
{
return *this;
}
~enable_shared_from_this() noexcept // ~weak_ptr<T> newer throws, so this call also must not throw
~enable_shared_from_this() BOOST_SP_NOEXCEPT // ~weak_ptr<T> newer throws, so this call also must not throw
{
}
@@ -57,12 +59,12 @@ public:
return p;
}
weak_ptr<T> weak_from_this() noexcept
weak_ptr<T> weak_from_this() BOOST_SP_NOEXCEPT
{
return weak_this_;
}
weak_ptr<T const> weak_from_this() const noexcept
weak_ptr<T const> weak_from_this() const BOOST_SP_NOEXCEPT
{
return weak_this_;
}
@@ -70,7 +72,7 @@ public:
public: // actually private, but avoids compiler template friendship issues
// Note: invoked automatically by shared_ptr; do not call
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> const * ppx, Y * py ) const noexcept
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> const * ppx, Y * py ) const BOOST_SP_NOEXCEPT
{
if( weak_this_.expired() )
{

View File

@@ -13,14 +13,24 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/smart_ptr/detail/sp_cxx20_constexpr.hpp>
#include <boost/smart_ptr/detail/sp_convertible.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <functional> // for std::less
#include <boost/assert.hpp>
#include <boost/config/workaround.hpp>
#include <boost/smart_ptr/detail/sp_convertible.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config/no_tr1/functional.hpp> // for std::less
#if !defined(BOOST_NO_IOSTREAM)
#if !defined(BOOST_NO_IOSFWD)
#include <iosfwd> // for std::basic_ostream
#include <cstddef>
#else
#include <ostream>
#endif
#endif
namespace boost
{
@@ -50,46 +60,64 @@ public:
typedef T element_type;
constexpr intrusive_ptr() noexcept : px( 0 )
BOOST_CONSTEXPR intrusive_ptr() BOOST_SP_NOEXCEPT : px( 0 )
{
}
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr( T * p, bool add_ref = true ): px( p )
intrusive_ptr( T * p, bool add_ref = true ): px( p )
{
if( px != 0 && add_ref ) intrusive_ptr_add_ref( px );
}
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
template<class U>
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr( intrusive_ptr<U> const & rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty() )
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
intrusive_ptr( intrusive_ptr<U> const & rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty() )
#else
intrusive_ptr( intrusive_ptr<U> const & rhs )
#endif
: px( rhs.get() )
{
if( px != 0 ) intrusive_ptr_add_ref( px );
}
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px )
#endif
intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px )
{
if( px != 0 ) intrusive_ptr_add_ref( px );
}
BOOST_SP_CXX20_CONSTEXPR ~intrusive_ptr()
~intrusive_ptr()
{
if( px != 0 ) intrusive_ptr_release( px );
}
template<class U> BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr<U> const & rhs)
#if !defined(BOOST_NO_MEMBER_TEMPLATES) || defined(BOOST_MSVC6_MEMBER_TEMPLATES)
template<class U> intrusive_ptr & operator=(intrusive_ptr<U> const & rhs)
{
this_type(rhs).swap(*this);
return *this;
}
#endif
// Move support
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr && rhs) noexcept : px( rhs.px )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
intrusive_ptr(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT : px( rhs.px )
{
rhs.px = 0;
}
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr && rhs) noexcept
intrusive_ptr & operator=(intrusive_ptr && rhs) BOOST_SP_NOEXCEPT
{
this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this);
return *this;
@@ -98,76 +126,84 @@ public:
template<class U> friend class intrusive_ptr;
template<class U>
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
#else
intrusive_ptr(intrusive_ptr<U> && rhs)
#endif
: px( rhs.px )
{
rhs.px = 0;
}
template<class U>
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr<U> && rhs) noexcept
intrusive_ptr & operator=(intrusive_ptr<U> && rhs) BOOST_SP_NOEXCEPT
{
this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this);
return *this;
}
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr const & rhs)
#endif
intrusive_ptr & operator=(intrusive_ptr const & rhs)
{
this_type(rhs).swap(*this);
return *this;
}
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(T * rhs)
intrusive_ptr & operator=(T * rhs)
{
this_type(rhs).swap(*this);
return *this;
}
BOOST_SP_CXX20_CONSTEXPR void reset()
void reset()
{
this_type().swap( *this );
}
BOOST_SP_CXX20_CONSTEXPR void reset( T * rhs )
void reset( T * rhs )
{
this_type( rhs ).swap( *this );
}
BOOST_SP_CXX20_CONSTEXPR void reset( T * rhs, bool add_ref )
void reset( T * rhs, bool add_ref )
{
this_type( rhs, add_ref ).swap( *this );
}
BOOST_SP_CXX20_CONSTEXPR T * get() const noexcept
T * get() const BOOST_SP_NOEXCEPT
{
return px;
}
BOOST_SP_CXX20_CONSTEXPR T * detach() noexcept
T * detach() BOOST_SP_NOEXCEPT
{
T * ret = px;
px = 0;
return ret;
}
BOOST_SP_CXX20_CONSTEXPR T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{
BOOST_ASSERT( px != 0 );
return *px;
}
BOOST_SP_CXX20_CONSTEXPR T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
{
BOOST_ASSERT( px != 0 );
return px;
}
BOOST_SP_CXX20_CONSTEXPR explicit operator bool () const noexcept
{
return px != 0;
}
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
BOOST_SP_CXX20_CONSTEXPR void swap(intrusive_ptr & rhs) noexcept
void swap(intrusive_ptr & rhs) BOOST_SP_NOEXCEPT
{
T * tmp = px;
px = rhs.px;
@@ -179,101 +215,118 @@ private:
T * px;
};
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(intrusive_ptr<T> const & a, U * b) noexcept
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, U * b) BOOST_SP_NOEXCEPT
{
return a.get() == b;
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, U * b) BOOST_SP_NOEXCEPT
{
return a.get() != b;
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(T * a, intrusive_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator==(T * a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a == b.get();
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a != b.get();
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator==( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
// Resolve the ambiguity between our op!= and the one in rel_ops
template<class T> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator==( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
template<class T> inline bool operator!=( intrusive_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept
#endif
template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) BOOST_SP_NOEXCEPT
{
return std::less<T *>()(a.get(), b.get());
}
template<class T> BOOST_SP_CXX20_CONSTEXPR inline void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) noexcept
template<class T> void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) BOOST_SP_NOEXCEPT
{
lhs.swap(rhs);
}
// mem_fn support
template<class T> BOOST_SP_CXX20_CONSTEXPR inline T * get_pointer(intrusive_ptr<T> const & p) noexcept
template<class T> T * get_pointer(intrusive_ptr<T> const & p) BOOST_SP_NOEXCEPT
{
return p.get();
}
// pointer casts
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & p)
template<class T, class U> intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & p)
{
return static_cast<T *>(p.get());
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
template<class T, class U> intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
{
return const_cast<T *>(p.get());
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
{
return dynamic_cast<T *>(p.get());
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> static_pointer_cast( intrusive_ptr<U> && p ) noexcept
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class T, class U> intrusive_ptr<T> static_pointer_cast( intrusive_ptr<U> && p ) BOOST_SP_NOEXCEPT
{
return intrusive_ptr<T>( static_cast<T*>( p.detach() ), false );
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> const_pointer_cast( intrusive_ptr<U> && p ) noexcept
template<class T, class U> intrusive_ptr<T> const_pointer_cast( intrusive_ptr<U> && p ) BOOST_SP_NOEXCEPT
{
return intrusive_ptr<T>( const_cast<T*>( p.detach() ), false );
}
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> dynamic_pointer_cast( intrusive_ptr<U> && p ) noexcept
template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast( intrusive_ptr<U> && p ) BOOST_SP_NOEXCEPT
{
T * p2 = dynamic_cast<T*>( p.get() );
@@ -284,19 +337,48 @@ template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> dyna
return r;
}
#endif // defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// operator<<
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y> const & p)
#if !defined(BOOST_NO_IOSTREAM)
#if defined(BOOST_NO_TEMPLATED_IOSTREAMS) || ( defined(__GNUC__) && (__GNUC__ < 3) )
template<class Y> std::ostream & operator<< (std::ostream & os, intrusive_ptr<Y> const & p)
{
os << p.get();
return os;
}
#else
// in STLport's no-iostreams mode no iostream symbols can be used
#ifndef _STLP_NO_IOSTREAMS
# if defined(BOOST_MSVC) && BOOST_WORKAROUND(BOOST_MSVC, < 1300 && __SGI_STL_PORT)
// MSVC6 has problems finding std::basic_ostream through the using declaration in namespace _STL
using std::basic_ostream;
template<class E, class T, class Y> basic_ostream<E, T> & operator<< (basic_ostream<E, T> & os, intrusive_ptr<Y> const & p)
# else
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y> const & p)
# endif
{
os << p.get();
return os;
}
#endif // _STLP_NO_IOSTREAMS
#endif // __GNUC__ < 3
#endif // !defined(BOOST_NO_IOSTREAM)
// hash_value
template< class T > struct hash;
template< class T > std::size_t hash_value( boost::intrusive_ptr<T> const & p ) noexcept
template< class T > std::size_t hash_value( boost::intrusive_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return boost::hash< T* >()( p.get() );
}
@@ -305,12 +387,14 @@ template< class T > std::size_t hash_value( boost::intrusive_ptr<T> const & p )
// std::hash
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
namespace std
{
template<class T> struct hash< ::boost::intrusive_ptr<T> >
{
std::size_t operator()( ::boost::intrusive_ptr<T> const & p ) const noexcept
std::size_t operator()( ::boost::intrusive_ptr<T> const & p ) const BOOST_SP_NOEXCEPT
{
return std::hash< T* >()( p.get() );
}
@@ -318,4 +402,6 @@ template<class T> struct hash< ::boost::intrusive_ptr<T> >
} // namespace std
#endif // #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
#endif // #ifndef BOOST_SMART_PTR_INTRUSIVE_PTR_HPP_INCLUDED

View File

@@ -15,8 +15,9 @@
#ifndef BOOST_SMART_PTR_INTRUSIVE_REF_COUNTER_HPP_INCLUDED_
#define BOOST_SMART_PTR_INTRUSIVE_REF_COUNTER_HPP_INCLUDED_
#include <boost/smart_ptr/detail/atomic_count.hpp>
#include <boost/config.hpp>
#include <boost/smart_ptr/detail/atomic_count.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#ifdef BOOST_HAS_PRAGMA_ONCE
#pragma once
@@ -45,17 +46,17 @@ struct thread_unsafe_counter
{
typedef unsigned int type;
static unsigned int load(unsigned int const& counter) noexcept
static unsigned int load(unsigned int const& counter) BOOST_SP_NOEXCEPT
{
return counter;
}
static void increment(unsigned int& counter) noexcept
static void increment(unsigned int& counter) BOOST_SP_NOEXCEPT
{
++counter;
}
static unsigned int decrement(unsigned int& counter) noexcept
static unsigned int decrement(unsigned int& counter) BOOST_SP_NOEXCEPT
{
return --counter;
}
@@ -71,17 +72,17 @@ struct thread_safe_counter
{
typedef boost::detail::atomic_count type;
static unsigned int load(boost::detail::atomic_count const& counter) noexcept
static unsigned int load(boost::detail::atomic_count const& counter) BOOST_SP_NOEXCEPT
{
return static_cast< unsigned int >(static_cast< long >(counter));
}
static void increment(boost::detail::atomic_count& counter) noexcept
static void increment(boost::detail::atomic_count& counter) BOOST_SP_NOEXCEPT
{
++counter;
}
static unsigned int decrement(boost::detail::atomic_count& counter) noexcept
static unsigned int decrement(boost::detail::atomic_count& counter) BOOST_SP_NOEXCEPT
{
return static_cast< unsigned int >(--counter);
}
@@ -91,9 +92,9 @@ template< typename DerivedT, typename CounterPolicyT = thread_safe_counter >
class intrusive_ref_counter;
template< typename DerivedT, typename CounterPolicyT >
void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept;
void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
template< typename DerivedT, typename CounterPolicyT >
void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept;
void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
/*!
* \brief A reference counter base class
@@ -121,7 +122,7 @@ public:
*
* \post <tt>use_count() == 0</tt>
*/
intrusive_ref_counter() noexcept : m_ref_counter(0)
intrusive_ref_counter() BOOST_SP_NOEXCEPT : m_ref_counter(0)
{
}
@@ -130,7 +131,7 @@ public:
*
* \post <tt>use_count() == 0</tt>
*/
intrusive_ref_counter(intrusive_ref_counter const&) noexcept : m_ref_counter(0)
intrusive_ref_counter(intrusive_ref_counter const&) BOOST_SP_NOEXCEPT : m_ref_counter(0)
{
}
@@ -139,12 +140,12 @@ public:
*
* \post The reference counter is not modified after assignment
*/
intrusive_ref_counter& operator= (intrusive_ref_counter const&) noexcept { return *this; }
intrusive_ref_counter& operator= (intrusive_ref_counter const&) BOOST_SP_NOEXCEPT { return *this; }
/*!
* \return The reference counter
*/
unsigned int use_count() const noexcept
unsigned int use_count() const BOOST_SP_NOEXCEPT
{
return CounterPolicyT::load(m_ref_counter);
}
@@ -155,18 +156,18 @@ protected:
*/
BOOST_DEFAULTED_FUNCTION(~intrusive_ref_counter(), {})
friend void intrusive_ptr_add_ref< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept;
friend void intrusive_ptr_release< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept;
friend void intrusive_ptr_add_ref< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
friend void intrusive_ptr_release< DerivedT, CounterPolicyT >(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT;
};
template< typename DerivedT, typename CounterPolicyT >
inline void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept
inline void intrusive_ptr_add_ref(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT
{
CounterPolicyT::increment(p->m_ref_counter);
}
template< typename DerivedT, typename CounterPolicyT >
inline void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) noexcept
inline void intrusive_ptr_release(const intrusive_ref_counter< DerivedT, CounterPolicyT >* p) BOOST_SP_NOEXCEPT
{
if (CounterPolicyT::decrement(p->m_ref_counter) == 0)
delete static_cast< const DerivedT* >(p);

View File

@@ -12,8 +12,6 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/assert.hpp>
namespace boost
{
@@ -128,7 +126,7 @@ public:
// destructor
~local_shared_ptr() noexcept
~local_shared_ptr() BOOST_SP_NOEXCEPT
{
if( pn )
{
@@ -138,16 +136,20 @@ public:
// constructors
constexpr local_shared_ptr() noexcept : px( 0 ), pn( 0 )
BOOST_CONSTEXPR local_shared_ptr() BOOST_SP_NOEXCEPT : px( 0 ), pn( 0 )
{
}
constexpr local_shared_ptr( std::nullptr_t ) noexcept : px( 0 ), pn( 0 )
#if !defined( BOOST_NO_CXX11_NULLPTR )
BOOST_CONSTEXPR local_shared_ptr( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn( 0 )
{
}
#endif
// internal constructor, used by make_shared
constexpr local_shared_ptr( boost::detail::lsp_internal_constructor_tag, element_type * px_, boost::detail::local_counted_base * pn_ ) noexcept : px( px_ ), pn( pn_ )
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, element_type * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
{
}
@@ -162,21 +164,29 @@ public:
boost::detail::lsp_deleter_construct( this, p, d, pn );
}
template<class D> local_shared_ptr( std::nullptr_t p, D d ): px( p ), pn( 0 )
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class D> local_shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( 0 )
{
boost::detail::lsp_deleter_construct( this, p, d, pn );
}
#endif
template<class Y, class D, class A> local_shared_ptr( Y * p, D d, A a ): px( p ), pn( 0 )
{
boost::detail::lsp_allocator_construct( this, p, d, a, pn );
}
template<class D, class A> local_shared_ptr( std::nullptr_t p, D d, A a ): px( p ), pn( 0 )
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class D, class A> local_shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( 0 )
{
boost::detail::lsp_allocator_construct( this, p, d, a, pn );
}
#endif
// construction from shared_ptr
template<class Y> local_shared_ptr( shared_ptr<Y> const & r,
@@ -191,6 +201,8 @@ public:
}
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> local_shared_ptr( shared_ptr<Y> && r,
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() )
: px( r.get() ), pn( 0 )
@@ -204,8 +216,12 @@ public:
}
}
#endif
// construction from unique_ptr
#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template< class Y, class D >
local_shared_ptr( std::unique_ptr< Y, D > && r,
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() )
@@ -219,6 +235,8 @@ public:
}
}
#endif
template< class Y, class D >
local_shared_ptr( boost::movelib::unique_ptr< Y, D > r ); // !
// : px( r.get() ), pn( new boost::detail::local_counted_impl( shared_ptr<T>( std::move(r) ) ) )
@@ -228,7 +246,7 @@ public:
// copy constructor
local_shared_ptr( local_shared_ptr const & r ) noexcept : px( r.px ), pn( r.pn )
local_shared_ptr( local_shared_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
if( pn )
{
@@ -238,16 +256,20 @@ public:
// move constructor
local_shared_ptr( local_shared_ptr && r ) noexcept : px( r.px ), pn( r.pn )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
local_shared_ptr( local_shared_ptr && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
r.px = 0;
r.pn = 0;
}
#endif
// converting copy constructor
template<class Y> local_shared_ptr( local_shared_ptr<Y> const & r,
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() ) noexcept
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() ) BOOST_SP_NOEXCEPT
: px( r.px ), pn( r.pn )
{
boost::detail::sp_assert_convertible< Y, T >();
@@ -260,8 +282,10 @@ public:
// converting move constructor
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> local_shared_ptr( local_shared_ptr<Y> && r,
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() ) noexcept
typename boost::detail::sp_enable_if_convertible<Y, T>::type = boost::detail::sp_empty() ) BOOST_SP_NOEXCEPT
: px( r.px ), pn( r.pn )
{
boost::detail::sp_assert_convertible< Y, T >();
@@ -270,10 +294,12 @@ public:
r.pn = 0;
}
#endif
// aliasing
template<class Y>
local_shared_ptr( local_shared_ptr<Y> const & r, element_type * p ) noexcept : px( p ), pn( r.pn )
local_shared_ptr( local_shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{
if( pn )
{
@@ -281,46 +307,60 @@ public:
}
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y>
local_shared_ptr( local_shared_ptr<Y> && r, element_type * p ) noexcept : px( p ), pn( r.pn )
local_shared_ptr( local_shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{
r.px = 0;
r.pn = 0;
}
#endif
// assignment
local_shared_ptr & operator=( local_shared_ptr const & r ) noexcept
local_shared_ptr & operator=( local_shared_ptr const & r ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( r ).swap( *this );
return *this;
}
template<class Y> local_shared_ptr & operator=( local_shared_ptr<Y> const & r ) noexcept
template<class Y> local_shared_ptr & operator=( local_shared_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( r ).swap( *this );
return *this;
}
local_shared_ptr & operator=( local_shared_ptr && r ) noexcept
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
local_shared_ptr & operator=( local_shared_ptr && r ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( std::move( r ) ).swap( *this );
return *this;
}
template<class Y>
local_shared_ptr & operator=( local_shared_ptr<Y> && r ) noexcept
local_shared_ptr & operator=( local_shared_ptr<Y> && r ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( std::move( r ) ).swap( *this );
return *this;
}
local_shared_ptr & operator=( std::nullptr_t ) noexcept
#endif
#if !defined( BOOST_NO_CXX11_NULLPTR )
local_shared_ptr & operator=( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
local_shared_ptr().swap(*this);
return *this;
}
#endif
#if !defined( BOOST_NO_CXX11_SMART_PTR ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y, class D>
local_shared_ptr & operator=( std::unique_ptr<Y, D> && r )
{
@@ -328,12 +368,14 @@ public:
return *this;
}
#endif
template<class Y, class D>
local_shared_ptr & operator=( boost::movelib::unique_ptr<Y, D> r ); // !
// reset
void reset() noexcept
void reset() BOOST_SP_NOEXCEPT
{
local_shared_ptr().swap( *this );
}
@@ -353,24 +395,28 @@ public:
local_shared_ptr( p, d, a ).swap( *this );
}
template<class Y> void reset( local_shared_ptr<Y> const & r, element_type * p ) noexcept
template<class Y> void reset( local_shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( r, p ).swap( *this );
}
template<class Y> void reset( local_shared_ptr<Y> && r, element_type * p ) noexcept
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> void reset( local_shared_ptr<Y> && r, element_type * p ) BOOST_SP_NOEXCEPT
{
local_shared_ptr( std::move( r ), p ).swap( *this );
}
#endif
// accessors
typename boost::detail::sp_dereference< T >::type operator* () const noexcept
typename boost::detail::sp_dereference< T >::type operator* () const BOOST_SP_NOEXCEPT
{
return *px;
}
typename boost::detail::sp_member_access< T >::type operator-> () const noexcept
typename boost::detail::sp_member_access< T >::type operator-> () const BOOST_SP_NOEXCEPT
{
return px;
}
@@ -383,24 +429,26 @@ public:
return static_cast< typename boost::detail::sp_array_access< T >::type >( px[ i ] );
}
element_type * get() const noexcept
element_type * get() const BOOST_SP_NOEXCEPT
{
return px;
}
explicit operator bool () const noexcept
{
return px != 0;
}
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
long local_use_count() const noexcept
long local_use_count() const BOOST_SP_NOEXCEPT
{
return pn? pn->local_use_count(): 0;
}
// conversions to shared_ptr, weak_ptr
template<class Y, class E = typename boost::detail::sp_enable_if_convertible<T,Y>::type> operator shared_ptr<Y>() const noexcept
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
template<class Y, class E = typename boost::detail::sp_enable_if_convertible<T,Y>::type> operator shared_ptr<Y>() const BOOST_SP_NOEXCEPT
#else
template<class Y> operator shared_ptr<Y>() const BOOST_SP_NOEXCEPT
#endif
{
boost::detail::sp_assert_convertible<T, Y>();
@@ -414,7 +462,11 @@ public:
}
}
template<class Y, class E = typename boost::detail::sp_enable_if_convertible<T,Y>::type> operator weak_ptr<Y>() const noexcept
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
template<class Y, class E = typename boost::detail::sp_enable_if_convertible<T,Y>::type> operator weak_ptr<Y>() const BOOST_SP_NOEXCEPT
#else
template<class Y> operator weak_ptr<Y>() const BOOST_SP_NOEXCEPT
#endif
{
boost::detail::sp_assert_convertible<T, Y>();
@@ -430,7 +482,7 @@ public:
// swap
void swap( local_shared_ptr & r ) noexcept
void swap( local_shared_ptr & r ) BOOST_SP_NOEXCEPT
{
std::swap( px, r.px );
std::swap( pn, r.pn );
@@ -438,80 +490,84 @@ public:
// owner_before
template<class Y> bool owner_before( local_shared_ptr<Y> const & r ) const noexcept
template<class Y> bool owner_before( local_shared_ptr<Y> const & r ) const BOOST_SP_NOEXCEPT
{
return std::less< boost::detail::local_counted_base* >()( pn, r.pn );
}
// owner_equals
template<class Y> bool owner_equals( local_shared_ptr<Y> const & r ) const noexcept
template<class Y> bool owner_equals( local_shared_ptr<Y> const & r ) const BOOST_SP_NOEXCEPT
{
return pn == r.pn;
}
};
template<class T, class U> inline bool operator==( local_shared_ptr<T> const & a, local_shared_ptr<U> const & b ) noexcept
template<class T, class U> inline bool operator==( local_shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();
}
template<class T, class U> inline bool operator!=( local_shared_ptr<T> const & a, local_shared_ptr<U> const & b ) noexcept
template<class T, class U> inline bool operator!=( local_shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
template<class T> inline bool operator==( local_shared_ptr<T> const & p, std::nullptr_t ) noexcept
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( local_shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( std::nullptr_t, local_shared_ptr<T> const & p ) noexcept
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( local_shared_ptr<T> const & p, std::nullptr_t ) noexcept
template<class T> inline bool operator!=( local_shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( std::nullptr_t, local_shared_ptr<T> const & p ) noexcept
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T, class U> inline bool operator==( local_shared_ptr<T> const & a, shared_ptr<U> const & b ) noexcept
#endif
template<class T, class U> inline bool operator==( local_shared_ptr<T> const & a, shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();
}
template<class T, class U> inline bool operator!=( local_shared_ptr<T> const & a, shared_ptr<U> const & b ) noexcept
template<class T, class U> inline bool operator!=( local_shared_ptr<T> const & a, shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
template<class T, class U> inline bool operator==( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) noexcept
template<class T, class U> inline bool operator==( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();
}
template<class T, class U> inline bool operator!=( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) noexcept
template<class T, class U> inline bool operator!=( shared_ptr<T> const & a, local_shared_ptr<U> const & b ) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
template<class T, class U> inline bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator<(local_shared_ptr<T> const & a, local_shared_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a.owner_before( b );
}
template<class T> inline void swap( local_shared_ptr<T> & a, local_shared_ptr<T> & b ) noexcept
template<class T> inline void swap( local_shared_ptr<T> & a, local_shared_ptr<T> & b ) BOOST_SP_NOEXCEPT
{
a.swap( b );
}
template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared_ptr<U> const & r ) noexcept
template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{
(void) static_cast< T* >( static_cast< U* >( 0 ) );
@@ -521,7 +577,7 @@ template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared
return local_shared_ptr<T>( r, p );
}
template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_ptr<U> const & r ) noexcept
template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{
(void) const_cast< T* >( static_cast< U* >( 0 ) );
@@ -531,7 +587,7 @@ template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_
return local_shared_ptr<T>( r, p );
}
template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_shared_ptr<U> const & r ) noexcept
template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
@@ -541,7 +597,7 @@ template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_share
return p? local_shared_ptr<T>( r, p ): local_shared_ptr<T>();
}
template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_shared_ptr<U> const & r ) noexcept
template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_shared_ptr<U> const & r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@@ -551,7 +607,9 @@ template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_s
return local_shared_ptr<T>( r, p );
}
template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared_ptr<U> && r ) noexcept
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) static_cast< T* >( static_cast< U* >( 0 ) );
@@ -561,7 +619,7 @@ template<class T, class U> local_shared_ptr<T> static_pointer_cast( local_shared
return local_shared_ptr<T>( std::move(r), p );
}
template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_ptr<U> && r ) noexcept
template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) const_cast< T* >( static_cast< U* >( 0 ) );
@@ -571,7 +629,7 @@ template<class T, class U> local_shared_ptr<T> const_pointer_cast( local_shared_
return local_shared_ptr<T>( std::move(r), p );
}
template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_shared_ptr<U> && r ) noexcept
template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) dynamic_cast< T* >( static_cast< U* >( 0 ) );
@@ -581,7 +639,7 @@ template<class T, class U> local_shared_ptr<T> dynamic_pointer_cast( local_share
return p? local_shared_ptr<T>( std::move(r), p ): local_shared_ptr<T>();
}
template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_shared_ptr<U> && r ) noexcept
template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_shared_ptr<U> && r ) BOOST_SP_NOEXCEPT
{
(void) reinterpret_cast< T* >( static_cast< U* >( 0 ) );
@@ -591,24 +649,30 @@ template<class T, class U> local_shared_ptr<T> reinterpret_pointer_cast( local_s
return local_shared_ptr<T>( std::move(r), p );
}
#endif // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// get_pointer() enables boost::mem_fn to recognize local_shared_ptr
template<class T> inline typename local_shared_ptr<T>::element_type * get_pointer( local_shared_ptr<T> const & p ) noexcept
template<class T> inline typename local_shared_ptr<T>::element_type * get_pointer( local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get();
}
// operator<<
#if !defined(BOOST_NO_IOSTREAM)
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< ( std::basic_ostream<E, T> & os, local_shared_ptr<Y> const & p )
{
os << p.get();
return os;
}
#endif // !defined(BOOST_NO_IOSTREAM)
// get_deleter
template<class D, class T> D * get_deleter( local_shared_ptr<T> const & p ) noexcept
template<class D, class T> D * get_deleter( local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return get_deleter<D>( shared_ptr<T>( p ) );
}
@@ -617,7 +681,7 @@ template<class D, class T> D * get_deleter( local_shared_ptr<T> const & p ) noex
template< class T > struct hash;
template< class T > std::size_t hash_value( local_shared_ptr<T> const & p ) noexcept
template< class T > std::size_t hash_value( local_shared_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return boost::hash< typename local_shared_ptr<T>::element_type* >()( p.get() );
}
@@ -626,12 +690,14 @@ template< class T > std::size_t hash_value( local_shared_ptr<T> const & p ) noex
// std::hash
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
namespace std
{
template<class T> struct hash< ::boost::local_shared_ptr<T> >
{
std::size_t operator()( ::boost::local_shared_ptr<T> const & p ) const noexcept
std::size_t operator()( ::boost::local_shared_ptr<T> const & p ) const BOOST_SP_NOEXCEPT
{
return std::hash< typename ::boost::local_shared_ptr<T>::element_type* >()( p.get() );
}
@@ -639,4 +705,6 @@ template<class T> struct hash< ::boost::local_shared_ptr<T> >
} // namespace std
#endif // #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
#endif // #ifndef BOOST_SMART_PTR_LOCAL_SHARED_PTR_HPP_INCLUDED

View File

@@ -11,13 +11,11 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/default_allocator.hpp>
#include <boost/smart_ptr/allocate_local_shared_array.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <type_traits>
namespace boost {
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared()
{
@@ -26,16 +24,16 @@ make_local_shared()
}
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared(const typename std::remove_extent<T>::type& value)
make_local_shared(const typename remove_extent<T>::type& value)
{
return boost::allocate_local_shared<T>(boost::default_allocator<typename
detail::sp_array_element<T>::type>(), value);
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared(std::size_t size)
{
@@ -44,17 +42,17 @@ make_local_shared(std::size_t size)
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared(std::size_t size,
const typename std::remove_extent<T>::type& value)
const typename remove_extent<T>::type& value)
{
return boost::allocate_local_shared<T>(boost::default_allocator<typename
detail::sp_array_element<T>::type>(), size, value);
}
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
inline typename enable_if_<is_bounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared_noinit()
{
@@ -63,7 +61,7 @@ make_local_shared_noinit()
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
local_shared_ptr<T> >::type
make_local_shared_noinit(std::size_t size)
{

View File

@@ -13,8 +13,8 @@
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/config.hpp>
#include <type_traits>
#include <utility>
#include <cstddef>
@@ -45,7 +45,7 @@ template<class T, class A> class lsp_ms_deleter: public local_counted_impl_em
{
private:
typedef typename sp_aligned_storage<sizeof(T), std::alignment_of<T>::value>::type storage_type;
typedef typename sp_aligned_storage<sizeof(T), ::boost::alignment_of<T>::value>::type storage_type;
storage_type storage_;
A a_;
@@ -53,49 +53,57 @@ private:
private:
void destroy() noexcept
void destroy() BOOST_SP_NOEXCEPT
{
if( initialized_ )
{
T * p = reinterpret_cast< T* >( storage_.data_ );
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
std::allocator_traits<A>::destroy( a_, p );
#else
p->~T();
#endif
initialized_ = false;
}
}
public:
explicit lsp_ms_deleter( A const & a ) noexcept : a_( a ), initialized_( false )
explicit lsp_ms_deleter( A const & a ) BOOST_SP_NOEXCEPT : a_( a ), initialized_( false )
{
}
// optimization: do not copy storage_
lsp_ms_deleter( lsp_ms_deleter const & r ) noexcept : a_( r.a_), initialized_( false )
lsp_ms_deleter( lsp_ms_deleter const & r ) BOOST_SP_NOEXCEPT : a_( r.a_), initialized_( false )
{
}
~lsp_ms_deleter() noexcept
~lsp_ms_deleter() BOOST_SP_NOEXCEPT
{
destroy();
}
void operator()( T * ) noexcept
void operator()( T * ) BOOST_SP_NOEXCEPT
{
destroy();
}
static void operator_fn( T* ) noexcept // operator() can't be static
static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
{
}
void * address() noexcept
void * address() BOOST_SP_NOEXCEPT
{
return storage_.data_;
}
void set_initialized() noexcept
void set_initialized() BOOST_SP_NOEXCEPT
{
initialized_ = true;
}
@@ -105,8 +113,16 @@ public:
template<class T, class A, class... Args> typename boost::detail::lsp_if_not_array<T>::type allocate_local_shared( A const & a, Args&&... args )
{
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc<T> A2;
#else
typedef typename A::template rebind<T>::other A2;
#endif
A2 a2( a );
typedef boost::detail::lsp_ms_deleter<T, A2> D;
@@ -116,8 +132,16 @@ template<class T, class A, class... Args> typename boost::detail::lsp_if_not_arr
D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
std::allocator_traits<A2>::construct( a2, static_cast< T* >( pv ), std::forward<Args>( args )... );
#else
::new( pv ) T( std::forward<Args>( args )... );
#endif
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
@@ -130,8 +154,16 @@ template<class T, class A, class... Args> typename boost::detail::lsp_if_not_arr
template<class T, class A> typename boost::detail::lsp_if_not_array<T>::type allocate_local_shared_noinit( A const & a )
{
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc<T> A2;
#else
typedef typename A::template rebind<T>::other A2;
#endif
A2 a2( a );
typedef boost::detail::lsp_ms_deleter< T, std::allocator<T> > D;
@@ -155,13 +187,13 @@ template<class T, class A> typename boost::detail::lsp_if_not_array<T>::type all
template<class T, class... Args> typename boost::detail::lsp_if_not_array<T>::type make_local_shared( Args&&... args )
{
typedef typename std::remove_const<T>::type T2;
typedef typename boost::remove_const<T>::type T2;
return boost::allocate_local_shared<T2>( std::allocator<T2>(), std::forward<Args>(args)... );
}
template<class T> typename boost::detail::lsp_if_not_array<T>::type make_local_shared_noinit()
{
typedef typename std::remove_const<T>::type T2;
typedef typename boost::remove_const<T>::type T2;
return boost::allocate_shared_noinit<T2>( std::allocator<T2>() );
}

View File

@@ -12,7 +12,10 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/make_shared_object.hpp>
#include <boost/smart_ptr/make_shared_array.hpp>
#include <boost/smart_ptr/allocate_shared_array.hpp>
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) && !defined( BOOST_NO_SFINAE )
# include <boost/smart_ptr/make_shared_array.hpp>
# include <boost/smart_ptr/allocate_shared_array.hpp>
#endif
#endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_HPP_INCLUDED

View File

@@ -10,13 +10,11 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/default_allocator.hpp>
#include <boost/smart_ptr/allocate_shared_array.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <type_traits>
namespace boost {
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared()
{
return boost::allocate_shared<T>(boost::default_allocator<typename
@@ -24,15 +22,15 @@ make_shared()
}
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared(const typename std::remove_extent<T>::type& value)
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared(const typename remove_extent<T>::type& value)
{
return boost::allocate_shared<T>(boost::default_allocator<typename
detail::sp_array_element<T>::type>(), value);
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared(std::size_t size)
{
return boost::allocate_shared<T>(boost::default_allocator<typename
@@ -40,15 +38,15 @@ make_shared(std::size_t size)
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared(std::size_t size, const typename std::remove_extent<T>::type& value)
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared(std::size_t size, const typename remove_extent<T>::type& value)
{
return boost::allocate_shared<T>(boost::default_allocator<typename
detail::sp_array_element<T>::type>(), size, value);
}
template<class T>
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
make_shared_noinit()
{
return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
@@ -56,7 +54,7 @@ make_shared_noinit()
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
make_shared_noinit(std::size_t size)
{
return boost::allocate_shared_noinit<T>(boost::default_allocator<typename

View File

@@ -11,16 +11,20 @@
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <boost/config.hpp>
#include <utility>
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_forward.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/type_traits/type_with_alignment.hpp>
#include <boost/type_traits/alignment_of.hpp>
#include <cstddef>
#include <new>
#include <type_traits>
namespace boost
{
namespace detail
{
@@ -29,7 +33,7 @@ template< std::size_t N, std::size_t A > struct sp_aligned_storage
union type
{
char data_[ N ];
typename sp_type_with_alignment< A >::type align_;
typename boost::type_with_alignment< A >::type align_;
};
};
@@ -37,14 +41,14 @@ template< class T > class sp_ms_deleter
{
private:
typedef typename sp_aligned_storage< sizeof( T ), std::alignment_of< T >::value >::type storage_type;
typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
bool initialized_;
storage_type storage_;
private:
void destroy() noexcept
void destroy() BOOST_SP_NOEXCEPT
{
if( initialized_ )
{
@@ -66,39 +70,39 @@ private:
public:
sp_ms_deleter() noexcept : initialized_( false )
sp_ms_deleter() BOOST_SP_NOEXCEPT : initialized_( false )
{
}
template<class A> explicit sp_ms_deleter( A const & ) noexcept : initialized_( false )
template<class A> explicit sp_ms_deleter( A const & ) BOOST_SP_NOEXCEPT : initialized_( false )
{
}
// optimization: do not copy storage_
sp_ms_deleter( sp_ms_deleter const & ) noexcept : initialized_( false )
sp_ms_deleter( sp_ms_deleter const & ) BOOST_SP_NOEXCEPT : initialized_( false )
{
}
~sp_ms_deleter() noexcept
~sp_ms_deleter() BOOST_SP_NOEXCEPT
{
destroy();
}
void operator()( T * ) noexcept
void operator()( T * ) BOOST_SP_NOEXCEPT
{
destroy();
}
static void operator_fn( T* ) noexcept // operator() can't be static
static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
{
}
void * address() noexcept
void * address() BOOST_SP_NOEXCEPT
{
return storage_.data_;
}
void set_initialized() noexcept
void set_initialized() BOOST_SP_NOEXCEPT
{
initialized_ = true;
}
@@ -108,7 +112,7 @@ template< class T, class A > class sp_as_deleter
{
private:
typedef typename sp_aligned_storage< sizeof( T ), std::alignment_of< T >::value >::type storage_type;
typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
storage_type storage_;
A a_;
@@ -116,49 +120,57 @@ private:
private:
void destroy() noexcept
void destroy() BOOST_SP_NOEXCEPT
{
if( initialized_ )
{
T * p = reinterpret_cast< T* >( storage_.data_ );
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
std::allocator_traits<A>::destroy( a_, p );
#else
p->~T();
#endif
initialized_ = false;
}
}
public:
sp_as_deleter( A const & a ) noexcept : a_( a ), initialized_( false )
sp_as_deleter( A const & a ) BOOST_SP_NOEXCEPT : a_( a ), initialized_( false )
{
}
// optimization: do not copy storage_
sp_as_deleter( sp_as_deleter const & r ) noexcept : a_( r.a_), initialized_( false )
sp_as_deleter( sp_as_deleter const & r ) BOOST_SP_NOEXCEPT : a_( r.a_), initialized_( false )
{
}
~sp_as_deleter() noexcept
~sp_as_deleter() BOOST_SP_NOEXCEPT
{
destroy();
}
void operator()( T * ) noexcept
void operator()( T * ) BOOST_SP_NOEXCEPT
{
destroy();
}
static void operator_fn( T* ) noexcept // operator() can't be static
static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
{
}
void * address() noexcept
void * address() BOOST_SP_NOEXCEPT
{
return storage_.data_;
}
void set_initialized() noexcept
void set_initialized() BOOST_SP_NOEXCEPT
{
initialized_ = true;
}
@@ -169,17 +181,29 @@ template< class T > struct sp_if_not_array
typedef boost::shared_ptr< T > type;
};
#if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
template< class T > struct sp_if_not_array< T[] >
{
};
#if !defined( BOOST_BORLANDC ) || !BOOST_WORKAROUND( BOOST_BORLANDC, < 0x600 )
template< class T, std::size_t N > struct sp_if_not_array< T[N] >
{
};
#endif
#endif
} // namespace detail
#define BOOST_SP_MSD( T ) boost::detail::sp_inplace_tag< boost::detail::sp_ms_deleter< T > >()
#if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
# define BOOST_SP_MSD( T ) boost::detail::sp_inplace_tag< boost::detail::sp_ms_deleter< T > >()
#else
# define BOOST_SP_MSD( T ) boost::detail::sp_ms_deleter< T >()
#endif
// _noinit versions
@@ -217,7 +241,9 @@ template< class T, class A > typename boost::detail::sp_if_not_array< T >::type
return boost::shared_ptr< T >( pt, pt2 );
}
//
#if !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// Variadic templates, rvalue reference
template< class T, class... Args > typename boost::detail::sp_if_not_array< T >::type make_shared( Args && ... args )
{
@@ -227,7 +253,7 @@ template< class T, class... Args > typename boost::detail::sp_if_not_array< T >:
void * pv = pd->address();
::new( pv ) T( std::forward<Args>( args )... );
::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
@@ -238,6 +264,8 @@ template< class T, class... Args > typename boost::detail::sp_if_not_array< T >:
template< class T, class A, class... Args > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, Args && ... args )
{
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
typedef typename std::allocator_traits<A>::template rebind_alloc<T> A2;
A2 a2( a );
@@ -245,10 +273,26 @@ template< class T, class A, class... Args > typename boost::detail::sp_if_not_ar
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a2 );
#else
typedef boost::detail::sp_ms_deleter< T > D;
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a );
#endif
D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
std::allocator_traits<A2>::construct( a2, static_cast< T* >( pv ), std::forward<Args>( args )... );
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
std::allocator_traits<A2>::construct( a2, static_cast< T* >( pv ), boost::detail::sp_forward<Args>( args )... );
#else
::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
#endif
pd->set_initialized();
@@ -258,6 +302,498 @@ template< class T, class A, class... Args > typename boost::detail::sp_if_not_ar
return boost::shared_ptr< T >( pt, pt2 );
}
#else // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// Common zero-argument versions
template< class T > typename boost::detail::sp_if_not_array< T >::type make_shared()
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T();
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T();
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
// C++03 version
template< class T, class A1 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4, class A5 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4, class A5 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4, class A5, class A6 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 ),
boost::forward<A8>( a8 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 ),
boost::forward<A8>( a8 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8, BOOST_FWD_REF(A9) a9 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 ),
boost::forward<A8>( a8 ),
boost::forward<A9>( a9 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8, BOOST_FWD_REF(A9) a9 )
{
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
void * pv = pd->address();
::new( pv ) T(
boost::forward<A1>( a1 ),
boost::forward<A2>( a2 ),
boost::forward<A3>( a3 ),
boost::forward<A4>( a4 ),
boost::forward<A5>( a5 ),
boost::forward<A6>( a6 ),
boost::forward<A7>( a7 ),
boost::forward<A8>( a8 ),
boost::forward<A9>( a9 )
);
pd->set_initialized();
T * pt2 = static_cast< T* >( pv );
boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
return boost::shared_ptr< T >( pt, pt2 );
}
#endif // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
#undef BOOST_SP_MSD
} // namespace boost

View File

@@ -8,55 +8,60 @@ Distributed under the Boost Software License, Version 1.0.
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
#define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_unbounded_array.hpp>
#include <boost/type_traits/remove_extent.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <memory>
#include <type_traits>
#include <utility>
namespace boost {
template<class T>
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
make_unique()
{
return std::unique_ptr<T>(new T());
}
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template<class T, class... Args>
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
template<class T>
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
make_unique(typename std::remove_reference<T>::type&& value)
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
make_unique(typename remove_reference<T>::type&& value)
{
return std::unique_ptr<T>(new T(std::move(value)));
}
template<class T>
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
make_unique_noinit()
{
return std::unique_ptr<T>(new T);
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T> >::type
make_unique(std::size_t size)
{
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]());
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]());
}
template<class T>
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
inline typename enable_if_<is_unbounded_array<T>::value,
std::unique_ptr<T> >::type
make_unique_noinit(std::size_t size)
{
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]);
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]);
}
} /* boost */

View File

@@ -5,6 +5,8 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
namespace boost
{
@@ -14,7 +16,7 @@ template<class T = void> struct owner_equal_to
typedef T first_argument_type;
typedef T second_argument_type;
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept
template<class U, class V> bool operator()( U const & u, V const & v ) const BOOST_NOEXCEPT
{
return u.owner_equals( v );
}

View File

@@ -5,6 +5,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <cstddef>
namespace boost
@@ -15,7 +16,7 @@ template<class T> struct owner_hash
typedef std::size_t result_type;
typedef T argument_type;
std::size_t operator()( T const & t ) const noexcept
std::size_t operator()( T const & t ) const BOOST_NOEXCEPT
{
return t.owner_hash_value();
}

View File

@@ -14,6 +14,8 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/config.hpp>
namespace boost
{
@@ -23,7 +25,7 @@ template<class T = void> struct owner_less
typedef T first_argument_type;
typedef T second_argument_type;
template<class U, class V> bool operator()( U const & u, V const & v ) const noexcept
template<class U, class V> bool operator()( U const & u, V const & v ) const BOOST_NOEXCEPT
{
return u.owner_before( v );
}

View File

@@ -10,11 +10,12 @@
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef> // for std::ptrdiff_t
@@ -22,6 +23,15 @@
namespace boost
{
// Debug hooks
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
void sp_array_constructor_hook(void * p);
void sp_array_destructor_hook(void * p);
#endif
// scoped_array extends scoped_ptr to arrays. Deletion of the array pointed to
// is guaranteed, either on destruction of the scoped_array or via an explicit
// reset(). Use shared_array or std::vector if your needs are more complex.
@@ -44,12 +54,18 @@ public:
typedef T element_type;
explicit scoped_array( T * p = 0 ) noexcept : px( p )
explicit scoped_array( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p )
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_array_constructor_hook( px );
#endif
}
~scoped_array() noexcept
~scoped_array() BOOST_SP_NOEXCEPT
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_array_destructor_hook( px );
#endif
boost::checked_array_delete( px );
}
@@ -66,17 +82,15 @@ public:
return px[i];
}
T * get() const noexcept
T * get() const BOOST_SP_NOEXCEPT
{
return px;
}
explicit operator bool () const noexcept
{
return px != 0;
}
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_array & b) noexcept
void swap(scoped_array & b) BOOST_SP_NOEXCEPT
{
T * tmp = b.px;
b.px = px;
@@ -84,27 +98,31 @@ public:
}
};
template<class T> inline bool operator==( scoped_array<T> const & p, std::nullptr_t ) noexcept
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( std::nullptr_t, scoped_array<T> const & p ) noexcept
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( scoped_array<T> const & p, std::nullptr_t ) noexcept
template<class T> inline bool operator!=( scoped_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( std::nullptr_t, scoped_array<T> const & p ) noexcept
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) noexcept
#endif
template<class T> inline void swap(scoped_array<T> & a, scoped_array<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);
}

View File

@@ -10,14 +10,13 @@
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/smart_ptr/detail/deprecated_macros.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/assert.hpp>
#include <boost/config/workaround.hpp>
#include <boost/config.hpp>
#include <cstddef>
#ifndef BOOST_NO_AUTO_PTR
# include <memory> // for std::auto_ptr
@@ -31,6 +30,15 @@
namespace boost
{
// Debug hooks
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
void sp_scalar_constructor_hook(void * p);
void sp_scalar_destructor_hook(void * p);
#endif
// scoped_ptr mimics a built-in pointer except that it guarantees deletion
// of the object pointed to, either on destruction of the scoped_ptr or via
// an explicit reset(). scoped_ptr is a simple solution for simple needs;
@@ -54,20 +62,29 @@ public:
typedef T element_type;
explicit scoped_ptr( T * p = 0 ) noexcept : px( p )
explicit scoped_ptr( T * p = 0 ) BOOST_SP_NOEXCEPT : px( p )
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_constructor_hook( px );
#endif
}
#ifndef BOOST_NO_AUTO_PTR
explicit scoped_ptr( std::auto_ptr<T> p ) noexcept : px( p.release() )
explicit scoped_ptr( std::auto_ptr<T> p ) BOOST_SP_NOEXCEPT : px( p.release() )
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_constructor_hook( px );
#endif
}
#endif
~scoped_ptr() noexcept
~scoped_ptr() BOOST_SP_NOEXCEPT
{
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
boost::sp_scalar_destructor_hook( px );
#endif
boost::checked_delete( px );
}
@@ -89,17 +106,15 @@ public:
return px;
}
T * get() const noexcept
T * get() const BOOST_SP_NOEXCEPT
{
return px;
}
explicit operator bool () const noexcept
{
return px != 0;
}
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
void swap(scoped_ptr & b) noexcept
void swap(scoped_ptr & b) BOOST_SP_NOEXCEPT
{
T * tmp = b.px;
b.px = px;
@@ -107,34 +122,38 @@ public:
}
};
template<class T> inline bool operator==( scoped_ptr<T> const & p, std::nullptr_t ) noexcept
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( std::nullptr_t, scoped_ptr<T> const & p ) noexcept
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( scoped_ptr<T> const & p, std::nullptr_t ) noexcept
template<class T> inline bool operator!=( scoped_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( std::nullptr_t, scoped_ptr<T> const & p ) noexcept
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, scoped_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) noexcept
#endif
template<class T> inline void swap(scoped_ptr<T> & a, scoped_ptr<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);
}
// get_pointer(p) is a generic way to say p.get()
template<class T> inline T * get_pointer(scoped_ptr<T> const & p) noexcept
template<class T> inline T * get_pointer(scoped_ptr<T> const & p) BOOST_SP_NOEXCEPT
{
return p.get();
}

View File

@@ -14,17 +14,22 @@
// See http://www.boost.org/libs/smart_ptr/ for documentation.
//
#include <boost/config.hpp> // for broken compiler workarounds
#include <memory> // TR1 cyclic inclusion fix
#include <boost/assert.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <boost/core/checked_delete.hpp>
#include <boost/assert.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <cstddef> // for std::ptrdiff_t
#include <algorithm> // for std::swap
#include <functional> // for std::less
#include <cstddef> // for std::ptrdiff_t
namespace boost
{
@@ -49,14 +54,18 @@ public:
typedef T element_type;
shared_array() noexcept : px( 0 ), pn()
shared_array() BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
shared_array( std::nullptr_t ) noexcept : px( 0 ), pn()
#if !defined( BOOST_NO_CXX11_NULLPTR )
shared_array( boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT : px( 0 ), pn()
{
}
#endif
template<class Y>
explicit shared_array( Y * p ): px( p ), pn( p, checked_array_deleter<Y>() )
{
@@ -82,23 +91,36 @@ public:
}
// generated copy constructor, destructor are fine...
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// ... except in C++0x, move disables the implicit copy
shared_array( shared_array const & r ) noexcept : px( r.px ), pn( r.pn )
shared_array( shared_array const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
shared_array( shared_array && r ) noexcept : px( r.px ), pn()
shared_array( shared_array && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn()
{
pn.swap( r.pn );
r.px = 0;
}
#endif
// conversion
template<class Y>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
shared_array( shared_array<Y> const & r, typename boost::detail::sp_enable_if_convertible< Y[], T[] >::type = boost::detail::sp_empty() )
noexcept : px( r.px ), pn( r.pn )
#else
shared_array( shared_array<Y> const & r )
#endif
BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
boost::detail::sp_assert_convertible< Y[], T[] >();
}
@@ -106,39 +128,47 @@ public:
// aliasing
template< class Y >
shared_array( shared_array<Y> const & r, element_type * p ) noexcept : px( p ), pn( r.pn )
shared_array( shared_array<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT : px( p ), pn( r.pn )
{
}
// assignment
shared_array & operator=( shared_array const & r ) noexcept
shared_array & operator=( shared_array const & r ) BOOST_SP_NOEXCEPT
{
this_type( r ).swap( *this );
return *this;
}
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1400)
template<class Y>
shared_array & operator=( shared_array<Y> const & r ) noexcept
shared_array & operator=( shared_array<Y> const & r ) BOOST_SP_NOEXCEPT
{
this_type( r ).swap( *this );
return *this;
}
shared_array & operator=( shared_array && r ) noexcept
#endif
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
shared_array & operator=( shared_array && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< shared_array && >( r ) ).swap( *this );
return *this;
}
template<class Y>
shared_array & operator=( shared_array<Y> && r ) noexcept
shared_array & operator=( shared_array<Y> && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< shared_array<Y> && >( r ) ).swap( *this );
return *this;
}
void reset() noexcept
#endif
void reset() BOOST_SP_NOEXCEPT
{
this_type().swap( *this );
}
@@ -159,7 +189,7 @@ public:
this_type( p, d, a ).swap( *this );
}
template<class Y> void reset( shared_array<Y> const & r, element_type * p ) noexcept
template<class Y> void reset( shared_array<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
{
this_type( r, p ).swap( *this );
}
@@ -171,33 +201,31 @@ public:
return px[i];
}
T * get() const noexcept
T * get() const BOOST_SP_NOEXCEPT
{
return px;
}
explicit operator bool () const noexcept
{
return px != 0;
}
// implicit conversion to "bool"
#include <boost/smart_ptr/detail/operator_bool.hpp>
bool unique() const noexcept
bool unique() const BOOST_SP_NOEXCEPT
{
return pn.unique();
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return pn.use_count();
}
void swap(shared_array<T> & other) noexcept
void swap(shared_array<T> & other) BOOST_SP_NOEXCEPT
{
std::swap(px, other.px);
pn.swap(other.pn);
}
void * _internal_get_deleter( boost::detail::sp_typeinfo_ const & ti ) const noexcept
void * _internal_get_deleter( boost::detail::sp_typeinfo_ const & ti ) const BOOST_SP_NOEXCEPT
{
return pn.get_deleter( ti );
}
@@ -211,47 +239,51 @@ private:
}; // shared_array
template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) noexcept
template<class T> inline bool operator==(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_NOEXCEPT
{
return a.get() == b.get();
}
template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) noexcept
template<class T> inline bool operator!=(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_NOEXCEPT
{
return a.get() != b.get();
}
template<class T> inline bool operator==( shared_array<T> const & p, std::nullptr_t ) noexcept
#if !defined( BOOST_NO_CXX11_NULLPTR )
template<class T> inline bool operator==( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator==( std::nullptr_t, shared_array<T> const & p ) noexcept
template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() == 0;
}
template<class T> inline bool operator!=( shared_array<T> const & p, std::nullptr_t ) noexcept
template<class T> inline bool operator!=( shared_array<T> const & p, boost::detail::sp_nullptr_t ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator!=( std::nullptr_t, shared_array<T> const & p ) noexcept
template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.get() != 0;
}
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) noexcept
#endif
template<class T> inline bool operator<(shared_array<T> const & a, shared_array<T> const & b) BOOST_SP_NOEXCEPT
{
return std::less<T*>()(a.get(), b.get());
}
template<class T> void swap(shared_array<T> & a, shared_array<T> & b) noexcept
template<class T> void swap(shared_array<T> & a, shared_array<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);
}
template< class D, class T > D * get_deleter( shared_array<T> const & p ) noexcept
template< class D, class T > D * get_deleter( shared_array<T> const & p ) BOOST_SP_NOEXCEPT
{
return static_cast< D * >( p._internal_get_deleter( BOOST_SP_TYPEID_(D) ) );
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,6 +15,7 @@
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
#include <memory>
#include <cstddef>
@@ -32,24 +33,29 @@ public:
typedef typename boost::detail::sp_element< T >::type element_type;
constexpr weak_ptr() noexcept : px(0), pn()
BOOST_CONSTEXPR weak_ptr() BOOST_SP_NOEXCEPT : px(0), pn()
{
}
// generated copy constructor, assignment, destructor are fine...
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
// ... except in C++0x, move disables the implicit copy
weak_ptr( weak_ptr const & r ) noexcept : px( r.px ), pn( r.pn )
weak_ptr( weak_ptr const & r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
}
weak_ptr & operator=( weak_ptr const & r ) noexcept
weak_ptr & operator=( weak_ptr const & r ) BOOST_SP_NOEXCEPT
{
px = r.px;
pn = r.pn;
return *this;
}
#endif
//
// The "obvious" converting constructor implementation:
//
@@ -68,15 +74,33 @@ public:
//
template<class Y>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
weak_ptr( weak_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
noexcept : px(r.lock().get()), pn(r.pn)
#else
weak_ptr( weak_ptr<Y> const & r )
#endif
BOOST_SP_NOEXCEPT : px(r.lock().get()), pn(r.pn)
{
boost::detail::sp_assert_convertible< Y, T >();
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
weak_ptr( weak_ptr<Y> && r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
noexcept : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
#else
weak_ptr( weak_ptr<Y> && r )
#endif
BOOST_SP_NOEXCEPT : px( r.lock().get() ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
{
boost::detail::sp_assert_convertible< Y, T >();
r.px = 0;
@@ -84,41 +108,57 @@ public:
// for better efficiency in the T == Y case
weak_ptr( weak_ptr && r )
noexcept : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
BOOST_SP_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::weak_count && >( r.pn ) )
{
r.px = 0;
}
// for better efficiency in the T == Y case
weak_ptr & operator=( weak_ptr && r ) noexcept
weak_ptr & operator=( weak_ptr && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< weak_ptr && >( r ) ).swap( *this );
return *this;
}
#endif
template<class Y>
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
weak_ptr( shared_ptr<Y> const & r, typename boost::detail::sp_enable_if_convertible<Y,T>::type = boost::detail::sp_empty() )
noexcept : px( r.px ), pn( r.pn )
#else
weak_ptr( shared_ptr<Y> const & r )
#endif
BOOST_SP_NOEXCEPT : px( r.px ), pn( r.pn )
{
boost::detail::sp_assert_convertible< Y, T >();
}
// aliasing
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) noexcept: px( p ), pn( r.pn )
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
{
}
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) noexcept: px( p ), pn( r.pn )
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
{
}
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) noexcept: px( p ), pn( std::move( r.pn ) )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( std::move( r.pn ) )
{
}
#endif
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
template<class Y>
weak_ptr & operator=( weak_ptr<Y> const & r ) noexcept
weak_ptr & operator=( weak_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
{
boost::detail::sp_assert_convertible< Y, T >();
@@ -128,15 +168,19 @@ public:
return *this;
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y>
weak_ptr & operator=( weak_ptr<Y> && r ) noexcept
weak_ptr & operator=( weak_ptr<Y> && r ) BOOST_SP_NOEXCEPT
{
this_type( static_cast< weak_ptr<Y> && >( r ) ).swap( *this );
return *this;
}
#endif
template<class Y>
weak_ptr & operator=( shared_ptr<Y> const & r ) noexcept
weak_ptr & operator=( shared_ptr<Y> const & r ) BOOST_SP_NOEXCEPT
{
boost::detail::sp_assert_convertible< Y, T >();
@@ -146,83 +190,92 @@ public:
return *this;
}
shared_ptr<T> lock() const noexcept
#endif
shared_ptr<T> lock() const BOOST_SP_NOEXCEPT
{
return shared_ptr<T>( *this, boost::detail::sp_nothrow_tag() );
}
long use_count() const noexcept
long use_count() const BOOST_SP_NOEXCEPT
{
return pn.use_count();
}
bool expired() const noexcept
bool expired() const BOOST_SP_NOEXCEPT
{
return pn.use_count() == 0;
}
bool _empty() const noexcept // extension, not in std::weak_ptr
bool _empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
{
return pn.empty();
}
bool empty() const noexcept // extension, not in std::weak_ptr
bool empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
{
return pn.empty();
}
void reset() noexcept
void reset() BOOST_SP_NOEXCEPT
{
this_type().swap(*this);
}
void swap(this_type & other) noexcept
void swap(this_type & other) BOOST_SP_NOEXCEPT
{
std::swap(px, other.px);
pn.swap(other.pn);
}
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const noexcept
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{
return pn < rhs.pn;
}
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const noexcept
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{
return pn < rhs.pn;
}
template<class Y> bool owner_equals( weak_ptr<Y> const & rhs ) const noexcept
template<class Y> bool owner_equals( weak_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{
return pn == rhs.pn;
}
template<class Y> bool owner_equals( shared_ptr<Y> const & rhs ) const noexcept
template<class Y> bool owner_equals( shared_ptr<Y> const & rhs ) const BOOST_SP_NOEXCEPT
{
return pn == rhs.pn;
}
std::size_t owner_hash_value() const noexcept
std::size_t owner_hash_value() const BOOST_SP_NOEXCEPT
{
return pn.hash_value();
}
// Tasteless as this may seem, making all members public allows member templates
// to work in the absence of member template friends. (Matthew Langston)
#ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
private:
template<class Y> friend class weak_ptr;
template<class Y> friend class shared_ptr;
#endif
element_type * px; // contained pointer
boost::detail::weak_count pn; // reference counter
}; // weak_ptr
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) noexcept
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b) BOOST_SP_NOEXCEPT
{
return a.owner_before( b );
}
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) noexcept
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b) BOOST_SP_NOEXCEPT
{
a.swap(b);
}
@@ -235,7 +288,7 @@ template<class T> weak_ptr( shared_ptr<T> ) -> weak_ptr<T>;
// hash_value
template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) noexcept
template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) BOOST_SP_NOEXCEPT
{
return p.owner_hash_value();
}
@@ -247,17 +300,21 @@ template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) noexc
namespace std
{
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
template<class T> struct hash< ::boost::weak_ptr<T> >
{
std::size_t operator()( ::boost::weak_ptr<T> const & p ) const noexcept
std::size_t operator()( ::boost::weak_ptr<T> const & p ) const BOOST_SP_NOEXCEPT
{
return p.owner_hash_value();
}
};
#endif // #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
template<class T> struct equal_to< ::boost::weak_ptr<T> >
{
bool operator()( ::boost::weak_ptr<T> const & a, ::boost::weak_ptr<T> const & b ) const noexcept
bool operator()( ::boost::weak_ptr<T> const & a, ::boost::weak_ptr<T> const & b ) const BOOST_SP_NOEXCEPT
{
return a.owner_equals( b );
}

View File

@@ -18,5 +18,5 @@
"maintainers": [
"Peter Dimov <pdimov -at- gmail.com>"
],
"cxxstd": "11"
"cxxstd": "03"
}

View File

@@ -10,6 +10,6 @@ if(HAVE_BOOST_TEST)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::smart_ptr Boost::core Boost::align Boost::atomic Boost::container_hash Boost::bind Boost::move Threads::Threads)
boost_test_jamfile(FILE Jamfile LINK_LIBRARIES Boost::smart_ptr Boost::core Boost::align Boost::atomic Boost::container_hash Boost::bind Threads::Threads)
endif()

View File

@@ -7,25 +7,13 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.0.1 ;
import-search /boost/config/checks ;
import config : requires ;
import testing ;
project
: requirements
<library>/boost/smart_ptr//boost_smart_ptr
<library>/boost/core//boost_core
<library>/boost/align//boost_align
<library>/boost/atomic//boost_atomic
<library>/boost/container_hash//boost_container_hash
<library>/boost/bind//boost_bind
<library>/boost/move//boost_move
<toolset>gcc:<cxxflags>-Wno-non-virtual-dtor
<toolset>gcc:<cxxflags>-Wno-deprecated-declarations
<toolset>gcc:<cxxflags>-Wno-delete-non-virtual-dtor
#<toolset>gcc:<cxxflags>-Wno-delete-non-virtual-dtor (not in 4.4/4.6)
;
# quick test (for CI)
@@ -69,16 +57,14 @@ run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ;
run spinlock_test.cpp ;
run spinlock_try_test.cpp ;
run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ;
run spinlock_pool_test.cpp ;
run spinlock_pool_test.cpp
: : :
# msvc-8.0, 9.0 optimizer codegen bug for `x % 41`
<toolset>msvc-8.0,<variant>release:<build>no
<toolset>msvc-9.0,<variant>release:<build>no ;
run make_shared_test.cpp ;
run make_shared_move_emulation_test.cpp
: : :
<toolset>clang-3.5,<cxxstd>03:<build>no
<toolset>clang-3.6,<cxxstd>03:<build>no
<toolset>clang-3.7,<cxxstd>03:<build>no
;
run make_shared_move_emulation_test.cpp ;
run make_shared_perfect_forwarding_test.cpp ;
run shared_ptr_convertible_test.cpp ;
run wp_convertible_test.cpp ;
@@ -94,7 +80,8 @@ run sp_recursive_assign2_test.cpp ;
run sp_recursive_assign_rv_test.cpp ;
run sp_recursive_assign2_rv_test.cpp ;
compile-fail auto_ptr_lv_fail.cpp ;
compile-fail auto_ptr_lv_fail.cpp
: <toolset>gcc-4.4.7:<build>no <toolset>gcc-4.4:<build>no ;
run atomic_count_test2.cpp ;
run sp_typeinfo_test.cpp ;
@@ -175,23 +162,33 @@ compile-fail array_fail_dereference.cpp ;
compile-fail array_fail_member_access.cpp ;
compile-fail array_fail_array_access.cpp ;
run make_shared_array_test.cpp ;
run make_shared_array_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run make_shared_arrays_test.cpp ;
run make_shared_array_throws_test.cpp ;
run make_shared_array_esft_test.cpp ;
run make_shared_array_noinit_test.cpp ;
run make_shared_array_value_test.cpp ;
run make_shared_array_throws_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run make_shared_array_esft_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run make_shared_array_noinit_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run make_shared_array_value_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run allocate_shared_array_test.cpp ;
run allocate_shared_arrays_test.cpp ;
run allocate_shared_array_throws_test.cpp ;
run allocate_shared_array_esft_test.cpp ;
run allocate_shared_array_noinit_test.cpp ;
run allocate_shared_array_value_test.cpp ;
run allocate_shared_array_throws_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run allocate_shared_array_esft_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run allocate_shared_array_noinit_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run allocate_shared_array_value_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run allocate_shared_array_construct_test.cpp ;
run make_unique_test.cpp ;
run make_unique_args_test.cpp ;
run make_unique_value_test.cpp ;
run make_unique_value_test.cpp
: : : <toolset>gcc-4.6:<cxxflags>-fno-deduce-init-list ;
run make_unique_noinit_test.cpp ;
run make_unique_throws_test.cpp ;
run make_unique_array_test.cpp ;
@@ -245,7 +242,6 @@ run atomic_sp_test.cpp ;
run sp_constexpr_test.cpp ;
run sp_constexpr_test2.cpp ;
compile ip_constexpr_test.cpp ;
run atomic_sp_constexpr_test.cpp ;
@@ -254,7 +250,8 @@ run shared_ptr_fn_test.cpp ;
run get_deleter_test2.cpp ;
run get_deleter_test3.cpp ;
run get_deleter_array_test2.cpp ;
run get_deleter_array_test3.cpp ;
run get_deleter_array_test3.cpp
: : : <toolset>msvc-8.0:<build>no ;
run sp_convertible_test2.cpp ;
@@ -276,13 +273,15 @@ run allocate_local_shared_test.cpp ;
run allocate_local_shared_esft_test.cpp ;
run make_local_shared_array_test.cpp ;
run make_local_shared_arrays_test.cpp ;
run make_local_shared_arrays_test.cpp
: : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run make_local_shared_array_throws_test.cpp ;
run make_local_shared_array_esft_test.cpp ;
run make_local_shared_array_noinit_test.cpp ;
run make_local_shared_array_value_test.cpp ;
run allocate_local_shared_array_test.cpp ;
run allocate_local_shared_arrays_test.cpp ;
run allocate_local_shared_arrays_test.cpp
: : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run allocate_local_shared_array_throws_test.cpp ;
run allocate_local_shared_array_esft_test.cpp ;
run allocate_local_shared_array_noinit_test.cpp ;
@@ -293,7 +292,8 @@ run local_sp_fn_test.cpp ;
run lsp_convertible_test.cpp ;
run lsp_convertible_test2.cpp ;
run make_shared_array_tmp_test.cpp ;
run make_shared_array_tmp_test.cpp
: : : <toolset>msvc-8.0:<build>no ;
run lw_thread_test.cpp
: : : <threading>multi ;
@@ -306,7 +306,7 @@ lib dll_test : dll_test_lib.cpp : <link>shared:<define>DLL_TEST_DYN_LINK=1 ;
explicit dll_test ;
run dll_test_main.cpp dll_test : : : <link>static : dll_test_static ;
run dll_test_main.cpp dll_test : : : <link>shared <undefined-sanitizer>norecover:<build>no : dll_test_shared ;
run dll_test_main.cpp dll_test : : : <link>shared : dll_test_shared ;
run make_shared_const_test.cpp ;
run make_local_shared_const_test.cpp ;
@@ -323,17 +323,17 @@ explicit abi_test_nt ;
run abi_test_main.cpp abi_test_mt : : : <define>BOOST_DISABLE_THREADS : abi_test_nt_mt ;
run abi_test_main.cpp abi_test_nt : : : : abi_test_mt_nt ;
# run abi_test_main.cpp abi_test_mt/<cxxstd>0x : : : <cxxstd>98 : abi_test_03_11 ;
# run abi_test_main.cpp abi_test_mt/<cxxstd>98 : : : <cxxstd>0x : abi_test_11_03 ;
run abi_test_main.cpp abi_test_mt/<cxxstd>0x : : : <cxxstd>98 : abi_test_03_11 ;
run abi_test_main.cpp abi_test_mt/<cxxstd>98 : : : <cxxstd>0x : abi_test_11_03 ;
run weak_ptr_alias_test.cpp ;
run weak_ptr_alias_move_test.cpp ;
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
run get_deleter_test.cpp : : : <rtti>off : get_deleter_test_no_rtti ;
run get_deleter_test2.cpp : : : <rtti>off : get_deleter_test2_no_rtti ;
run get_deleter_test3.cpp : : : <rtti>off : get_deleter_test3_no_rtti ;
run get_deleter_test.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test_no_rtti ;
run get_deleter_test2.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test2_no_rtti ;
run get_deleter_test3.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test3_no_rtti ;
run shared_from_test.cpp ;
run weak_from_test.cpp ;
@@ -362,18 +362,11 @@ compile-fail shared_from_fail.cpp ;
compile-fail weak_from_fail.cpp ;
compile sp_override_test.cpp ;
local gcc-flags = -Wundef ;
compile sp_pedantic_test.cpp
: <warnings>pedantic
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<warnings-as-errors>on
<toolset>gcc:<cxxflags>$(gcc-flags)
<toolset>clang:<warnings-as-errors>on
<toolset>clang:<cxxflags>$(gcc-flags)
<toolset>clang-15:<cxxflags>-Wno-deprecated-builtins
;
<toolset>clang:<warnings-as-errors>on ;
run sp_owner_before_test.cpp ;
run sp_owner_equals_test.cpp ;
@@ -387,7 +380,6 @@ run owner_less_test2.cpp ;
run ip_hash_test2.cpp ;
run sp_hash_test4.cpp ;
run lsp_hash_test.cpp ;
run lsp_hash_test2.cpp ;
@@ -420,15 +412,3 @@ run sp_unordered_test.cpp ;
run sp_unique_ptr_test2.cpp ;
run sp_move_only_deleter.cpp ;
run sp_is_bounded_array_test.cpp ;
run sp_is_unbounded_array_test.cpp ;
run sp_type_identity_test.cpp ;
run sp_type_with_alignment_test.cpp ;
run sp_ostream_test.cpp ;
run ip_ostream_test.cpp ;
run lsp_ostream_test.cpp ;
run shared_ptr_alloc_test.cpp ;
run quick_allocator_test.cpp ;

View File

@@ -5,9 +5,12 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
struct allow { };
@@ -154,3 +157,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,10 +5,12 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
@@ -93,3 +95,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,12 +5,14 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <type_traits>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
@@ -87,7 +89,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[3]> result =
@@ -95,7 +97,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[][2]> result =
@@ -103,7 +105,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[2][2]> result =
@@ -111,7 +113,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[]> result =
@@ -119,7 +121,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[3]> result =
@@ -127,7 +129,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[][2]> result =
@@ -135,7 +137,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[2][2]> result =
@@ -143,7 +145,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<type[]> result =
@@ -151,7 +153,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> other = result;
result.reset();
@@ -163,7 +165,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> other = result;
result.reset();
@@ -175,7 +177,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[][2]> other = result;
result.reset();
@@ -187,7 +189,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[2][2]> other = result;
result.reset();
@@ -199,7 +201,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[]> other = result;
result.reset();
@@ -211,7 +213,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[3]> other = result;
result.reset();
@@ -224,7 +226,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[][2]> other = result;
result.reset();
@@ -236,7 +238,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[2][2]> other = result;
result.reset();
@@ -244,3 +246,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,12 +5,14 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <type_traits>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
@@ -87,7 +89,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -98,7 +100,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -109,7 +111,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -121,7 +123,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -133,7 +135,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -144,7 +146,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -155,7 +157,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -167,7 +169,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -179,7 +181,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> w1 = result;
result.reset();
@@ -191,7 +193,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> w1 = result;
result.reset();
@@ -203,7 +205,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -214,7 +216,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -225,7 +227,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -236,7 +238,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -247,7 +249,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -258,10 +260,16 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,11 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
@@ -120,3 +122,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,11 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
@@ -82,3 +84,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,12 @@ Copyright 2017 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
@@ -82,3 +85,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -6,11 +6,20 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) || defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
int main()
{
}
#else
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <memory>
class X: public boost::enable_shared_from_this<X>
@@ -285,3 +294,5 @@ int main()
return boost::report_errors();
}
#endif

View File

@@ -6,11 +6,20 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) || defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
int main()
{
}
#else
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
class X
@@ -222,3 +231,5 @@ int main()
return boost::report_errors();
}
#endif

View File

@@ -15,6 +15,8 @@
#include <boost/config.hpp>
#include <cstddef>
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
template< class T > class cxx11_allocator
{
public:
@@ -228,3 +230,12 @@ int main()
return boost::report_errors();
}
#else // !defined( BOOST_NO_CXX11_ALLOCATOR )
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,10 @@ Copyright 2012-2015 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
struct allow { };
@@ -154,3 +155,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <type_traits>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
@@ -86,7 +86,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<int[3]> result =
@@ -94,7 +94,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<int[][2]> result =
@@ -102,7 +102,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<int[2][2]> result =
@@ -110,7 +110,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<const int[]> result =
@@ -118,7 +118,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<const int[3]> result =
@@ -126,7 +126,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<const int[][2]> result =
@@ -134,7 +134,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<const int[2][2]> result =
@@ -142,7 +142,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
}
{
boost::shared_ptr<type[]> result =
@@ -150,7 +150,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> other = result;
result.reset();
@@ -162,7 +162,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> other = result;
result.reset();
@@ -174,7 +174,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[][2]> other = result;
result.reset();
@@ -186,7 +186,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[2][2]> other = result;
result.reset();
@@ -198,7 +198,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[]> other = result;
result.reset();
@@ -210,7 +210,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[3]> other = result;
result.reset();
@@ -223,7 +223,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[][2]> other = result;
result.reset();
@@ -235,7 +235,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[2][2]> other = result;
result.reset();

View File

@@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <type_traits>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
@@ -86,7 +86,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -97,7 +97,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -108,7 +108,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -120,7 +120,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -132,7 +132,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -143,7 +143,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
@@ -154,7 +154,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -166,7 +166,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<int>::value));
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
@@ -178,7 +178,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> w1 = result;
result.reset();
@@ -190,7 +190,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> w1 = result;
result.reset();
@@ -202,7 +202,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -213,7 +213,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -224,7 +224,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -235,7 +235,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -246,7 +246,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
@@ -257,7 +257,7 @@ int main()
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
std::alignment_of<type>::value));
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);

View File

@@ -5,9 +5,10 @@ Copyright 2012-2015 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/smart_ptr/make_shared.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T = void>
struct creator {
@@ -82,3 +83,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -8,12 +8,14 @@
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/lightweight_test.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
#include <cstddef>
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
template< class T > class cxx11_allocator
{
public:
@@ -227,3 +229,12 @@ int main()
return boost::report_errors();
}
#else // !defined( BOOST_NO_CXX11_ALLOCATOR )
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,13 @@ Copyright 2019 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
BOOST_LIBSTDCXX_VERSION >= 46000) && \
!defined(BOOST_NO_CXX11_SMART_PTR) && \
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/smart_ptr/allocate_unique.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
template<class T = void>
struct creator {
@@ -72,3 +76,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,13 @@ Copyright 2019 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
BOOST_LIBSTDCXX_VERSION >= 46000) && \
!defined(BOOST_NO_CXX11_SMART_PTR) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/smart_ptr/allocate_unique.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
template<class T = void>
struct creator {
@@ -99,3 +103,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,13 @@ Copyright 2019 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
BOOST_LIBSTDCXX_VERSION >= 48000) && \
!defined(BOOST_NO_CXX11_SMART_PTR) && \
!defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/smart_ptr/allocate_unique.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
struct allow { };
@@ -154,3 +158,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,12 @@ Copyright 2019 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
BOOST_LIBSTDCXX_VERSION >= 48000) && \
!defined(BOOST_NO_CXX11_SMART_PTR)
#include <boost/smart_ptr/allocate_unique.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
template<class T = void>
struct creator {
@@ -217,3 +220,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,9 +5,12 @@ Copyright 2019 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
BOOST_LIBSTDCXX_VERSION >= 48000) && \
!defined(BOOST_NO_CXX11_SMART_PTR)
#include <boost/smart_ptr/allocate_unique.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
template<class T = void>
struct creator {
@@ -229,3 +232,9 @@ int main()
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

Some files were not shown because too many files have changed in this diff Show More