forked from boostorg/smart_ptr
Compare commits
47 Commits
feature/re
...
feature/qu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82e80c7175 | ||
|
|
81318213a6 | ||
|
|
85c2a6ea74 | ||
|
|
9723621128 | ||
|
|
6dffeb8a75 | ||
|
|
bee3766c04 | ||
|
|
86a873a58c | ||
|
|
c808ca7ac8 | ||
|
|
a4e0508ab7 | ||
|
|
1dcc441ca1 | ||
|
|
cdf118b15b | ||
|
|
ab75e1f892 | ||
|
|
dcfb560de3 | ||
|
|
362fb1d677 | ||
|
|
79dac0e691 | ||
|
|
d08d035bdf | ||
|
|
709e446968 | ||
|
|
0b0924ff82 | ||
|
|
e7433ba545 | ||
|
|
785a17aaaf | ||
|
|
576d31f206 | ||
|
|
1b89a64e9b | ||
|
|
840e2ff1a8 | ||
|
|
622e2c3f83 | ||
|
|
0630607f39 | ||
|
|
316f4cef77 | ||
|
|
9e866b8a95 | ||
|
|
cd01b87478 | ||
|
|
b3a4c39456 | ||
|
|
5cdd3585db | ||
|
|
916c8a7d7c | ||
|
|
beaf20e7b5 | ||
|
|
5e6b3a9702 | ||
|
|
63589908b5 | ||
|
|
9466e73cbe | ||
|
|
b12e342c52 | ||
|
|
7f880bc205 | ||
|
|
90fd5a1fc9 | ||
|
|
0bedddbf16 | ||
|
|
173cf9ad7b | ||
|
|
9db2b96843 | ||
|
|
9b309184f8 | ||
|
|
7c87ae7985 | ||
|
|
f2abcf1654 | ||
|
|
1361171bac | ||
|
|
c5023afe04 | ||
|
|
7cfc326207 |
@@ -34,7 +34,6 @@ local linux_pipeline(name, image, environment, packages = "", sources = [], arch
|
||||
'set -e',
|
||||
'uname -a',
|
||||
'echo $DRONE_STAGE_MACHINE',
|
||||
'wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -',
|
||||
] +
|
||||
(if sources != [] then [ ('apt-add-repository "' + source + '"') for source in sources ] else []) +
|
||||
(if packages != "" then [ 'apt-get update', 'apt-get -y install ' + packages ] else []) +
|
||||
@@ -179,22 +178,22 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 GCC 13 32 ASAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
"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 23.04 GCC 13 32 UBSAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
"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 23.04 GCC 13 64 UBSAN",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
"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",
|
||||
),
|
||||
@@ -333,38 +332,45 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.04 Clang 16",
|
||||
"cppalliance/droneubuntu2304:1",
|
||||
"Linux 24.04 Clang 16",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-16', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-16",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.10 Clang 17 UBSAN",
|
||||
"cppalliance/droneubuntu2310:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"Linux 24.04 Clang 17",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.10 Clang 17 ASAN",
|
||||
"cppalliance/droneubuntu2310:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 UBSAN",
|
||||
"Linux 24.04 Clang 18",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.04 Clang 18 ASAN",
|
||||
"Linux 24.04 Clang 19",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-18', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-18",
|
||||
{ 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(
|
||||
|
||||
132
.github/workflows/ci.yml
vendored
132
.github/workflows/ci.yml
vendored
@@ -19,41 +19,44 @@ jobs:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "11"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-4.8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-5
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-5-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-6
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-6-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-7
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: g++-7-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-8
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-9-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: g++-10-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-11
|
||||
@@ -69,65 +72,81 @@ jobs:
|
||||
- toolset: gcc-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
install: g++-13-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-14
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
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"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "11,14"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "11,14,1z"
|
||||
os: ubuntu-latest
|
||||
container: ubuntu:18.04
|
||||
os: ubuntu-latest
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "11,14,17"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-10
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-11
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
container: ubuntu:20.04
|
||||
os: ubuntu-latest
|
||||
install: clang-12
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
@@ -149,13 +168,13 @@ jobs:
|
||||
- toolset: clang
|
||||
compiler: clang++-16
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:23.04
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-16
|
||||
- toolset: clang
|
||||
compiler: clang++-17
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
container: ubuntu:23.10
|
||||
container: ubuntu:24.04
|
||||
os: ubuntu-latest
|
||||
install: clang-17
|
||||
- toolset: clang
|
||||
@@ -165,34 +184,54 @@ jobs:
|
||||
os: ubuntu-latest
|
||||
install: clang-18
|
||||
- toolset: clang
|
||||
cxxstd: "11,14,17,20,2b"
|
||||
os: macos-12
|
||||
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
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
container: ${{matrix.container}}
|
||||
|
||||
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: Enable Node 16
|
||||
run: |
|
||||
echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup container environment
|
||||
if: matrix.container
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get -y install sudo python3 git g++
|
||||
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
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
@@ -237,14 +276,6 @@ 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
|
||||
@@ -256,7 +287,7 @@ jobs:
|
||||
- toolset: gcc
|
||||
cxxstd: "11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
os: windows-2022
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -296,11 +327,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -344,11 +375,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -402,11 +433,11 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-12
|
||||
- os: ubuntu-24.04
|
||||
- os: macos-13
|
||||
- os: macos-14
|
||||
- os: macos-15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -458,8 +489,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -507,8 +537,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -574,8 +603,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
- os: windows-2022
|
||||
- os: windows-latest
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ target_link_libraries(boost_smart_ptr
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
||||
|
||||
target_compile_features(boost_smart_ptr INTERFACE cxx_std_11)
|
||||
|
||||
28
appveyor.yml
28
appveyor.yml
@@ -21,6 +21,22 @@ environment:
|
||||
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
|
||||
@@ -33,14 +49,14 @@ environment:
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\mingw\bin;
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
|
||||
ADDPATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 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;
|
||||
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;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 11,14,1z
|
||||
CXXSTD: 11,14,17
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
|
||||
@@ -10,7 +10,6 @@ constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/core//boost_core
|
||||
/boost/throw_exception//boost_throw_exception
|
||||
/boost/type_traits//boost_type_traits
|
||||
;
|
||||
|
||||
project /boost/smart_ptr ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2019, 2020 Peter Dimov
|
||||
Copyright 2019-2025 Peter Dimov
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@@ -13,6 +13,10 @@ 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.
|
||||
|
||||
@@ -210,7 +210,8 @@ T* get() const noexcept;
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The stored pointer.
|
||||
Returns::
|
||||
The stored pointer.
|
||||
|
||||
### unique
|
||||
|
||||
@@ -220,8 +221,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
|
||||
|
||||
@@ -253,7 +254,8 @@ 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
|
||||
|
||||
|
||||
@@ -1,270 +0,0 @@
|
||||
//
|
||||
// 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/smart_ptr/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)
|
||||
@@ -1,227 +0,0 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
void * operator new(size_t n, nothrow_t const &) throw()
|
||||
{
|
||||
return allocate(n, allocated_scalar);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void * operator new[](size_t n, nothrow_t const &) throw()
|
||||
{
|
||||
return allocate(n, allocated_array);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
void operator delete(void * p, nothrow_t const &) throw()
|
||||
{
|
||||
::operator delete(p);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void operator delete[](void * p, nothrow_t const &) throw()
|
||||
{
|
||||
::operator delete[](p);
|
||||
}
|
||||
|
||||
#endif // defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
@@ -10,6 +10,8 @@ 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 {
|
||||
@@ -69,7 +71,7 @@ private:
|
||||
} /* detail */
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator, std::size_t count)
|
||||
{
|
||||
@@ -89,12 +91,12 @@ allocate_local_shared(const A& allocator, std::size_t count)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator)
|
||||
{
|
||||
enum {
|
||||
count = extent<T>::value
|
||||
count = std::extent<T>::value
|
||||
};
|
||||
typedef typename detail::sp_array_element<T>::type element;
|
||||
typedef typename allocator_rebind<A, element>::type other;
|
||||
@@ -112,10 +114,10 @@ allocate_local_shared(const A& allocator)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator, std::size_t count,
|
||||
const typename remove_extent<T>::type& value)
|
||||
const typename std::remove_extent<T>::type& value)
|
||||
{
|
||||
typedef typename detail::sp_array_element<T>::type element;
|
||||
typedef typename allocator_rebind<A, element>::type other;
|
||||
@@ -133,13 +135,13 @@ allocate_local_shared(const A& allocator, std::size_t count,
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator,
|
||||
const typename remove_extent<T>::type& value)
|
||||
const typename std::remove_extent<T>::type& value)
|
||||
{
|
||||
enum {
|
||||
count = extent<T>::value
|
||||
count = std::extent<T>::value
|
||||
};
|
||||
typedef typename detail::sp_array_element<T>::type element;
|
||||
typedef typename allocator_rebind<A, element>::type other;
|
||||
@@ -157,7 +159,7 @@ allocate_local_shared(const A& allocator,
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared_noinit(const A& allocator, std::size_t count)
|
||||
{
|
||||
@@ -166,7 +168,7 @@ allocate_local_shared_noinit(const A& allocator, std::size_t count)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared_noinit(const A& allocator)
|
||||
{
|
||||
|
||||
@@ -12,22 +12,16 @@ 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/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>
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct sp_array_element {
|
||||
typedef typename boost::remove_cv<typename
|
||||
boost::remove_extent<T>::type>::type type;
|
||||
typedef typename std::remove_cv<typename
|
||||
std::remove_extent<T>::type>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -112,8 +106,8 @@ private:
|
||||
template<class T, class U>
|
||||
struct sp_array_alignment {
|
||||
enum {
|
||||
value = sp_max_size<boost::alignment_of<T>::value,
|
||||
boost::alignment_of<U>::value>::value
|
||||
value = sp_max_size<std::alignment_of<T>::value,
|
||||
std::alignment_of<U>::value>::value
|
||||
};
|
||||
};
|
||||
|
||||
@@ -142,7 +136,7 @@ class sp_array_creator {
|
||||
offset = sp_array_offset<T, element>::value
|
||||
};
|
||||
|
||||
typedef typename boost::type_with_alignment<sp_array_alignment<T,
|
||||
typedef typename sp_type_with_alignment<sp_array_alignment<T,
|
||||
element>::value>::type type;
|
||||
|
||||
public:
|
||||
@@ -258,7 +252,7 @@ private:
|
||||
} /* detail */
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_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;
|
||||
@@ -275,15 +269,15 @@ allocate_shared(const A& allocator, std::size_t count)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
allocate_shared(const A& allocator)
|
||||
{
|
||||
enum {
|
||||
count = extent<T>::value
|
||||
count = std::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, extent<T>::value> state;
|
||||
typedef detail::sp_size_array_state<other, std::extent<T>::value> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
detail::sp_array_result<other, base> result(allocator, count);
|
||||
base* node = result.get();
|
||||
@@ -295,9 +289,9 @@ allocate_shared(const A& allocator)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
allocate_shared(const A& allocator, std::size_t count,
|
||||
const typename remove_extent<T>::type& value)
|
||||
const typename std::remove_extent<T>::type& value)
|
||||
{
|
||||
typedef typename detail::sp_array_element<T>::type element;
|
||||
typedef typename allocator_rebind<A, element>::type other;
|
||||
@@ -313,16 +307,16 @@ allocate_shared(const A& allocator, std::size_t count,
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
allocate_shared(const A& allocator,
|
||||
const typename remove_extent<T>::type& value)
|
||||
const typename std::remove_extent<T>::type& value)
|
||||
{
|
||||
enum {
|
||||
count = extent<T>::value
|
||||
count = std::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, extent<T>::value> state;
|
||||
typedef detail::sp_size_array_state<other, std::extent<T>::value> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
detail::sp_array_result<other, base> result(allocator, count);
|
||||
base* node = result.get();
|
||||
@@ -334,14 +328,14 @@ allocate_shared(const A& allocator,
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_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 enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
allocate_shared_noinit(const A& allocator)
|
||||
{
|
||||
return boost::allocate_shared<T>(boost::noinit_adapt(allocator));
|
||||
|
||||
@@ -14,18 +14,12 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/first_scalar.hpp>
|
||||
#include <boost/core/noinit_adaptor.hpp>
|
||||
#include <boost/core/pointer_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/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
@@ -57,8 +51,8 @@ struct sp_alloc_result<T[N]> {
|
||||
|
||||
template<class T>
|
||||
struct sp_alloc_value {
|
||||
typedef typename boost::remove_cv<typename
|
||||
boost::remove_extent<T>::type>::type type;
|
||||
typedef typename std::remove_cv<typename
|
||||
std::remove_extent<T>::type>::type type;
|
||||
};
|
||||
|
||||
template<class T, class P>
|
||||
@@ -71,7 +65,7 @@ public:
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC == 1600
|
||||
sp_alloc_ptr(T* p) noexcept
|
||||
: p_(const_cast<typename boost::remove_cv<T>::type*>(p)) { }
|
||||
: p_(const_cast<typename std::remove_cv<T>::type*>(p)) { }
|
||||
#endif
|
||||
|
||||
sp_alloc_ptr(std::size_t, P p) noexcept
|
||||
@@ -108,7 +102,7 @@ public:
|
||||
static sp_alloc_ptr pointer_to(T& v) {
|
||||
return sp_alloc_ptr(1,
|
||||
std::pointer_traits<P>::pointer_to(const_cast<typename
|
||||
boost::remove_cv<T>::type&>(v)));
|
||||
std::remove_cv<T>::type&>(v)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -155,7 +149,7 @@ public:
|
||||
static sp_alloc_ptr pointer_to(T& v) {
|
||||
return sp_alloc_ptr(n_,
|
||||
std::pointer_traits<P>::pointer_to(const_cast<typename
|
||||
boost::remove_cv<T>::type&>(v)));
|
||||
std::remove_cv<T>::type&>(v)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -202,7 +196,7 @@ public:
|
||||
static sp_alloc_ptr pointer_to(T& v) {
|
||||
return sp_alloc_ptr(N,
|
||||
std::pointer_traits<P>::pointer_to(const_cast<typename
|
||||
boost::remove_cv<T>::type&>(v)));
|
||||
std::remove_cv<T>::type&>(v)));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -259,7 +253,7 @@ operator!=(std::nullptr_t,
|
||||
template<class A>
|
||||
inline void
|
||||
sp_alloc_clear(A& a, typename boost::allocator_pointer<A>::type p, std::size_t,
|
||||
boost::false_type)
|
||||
std::false_type)
|
||||
{
|
||||
boost::alloc_destroy(a, boost::to_address(p));
|
||||
}
|
||||
@@ -267,7 +261,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, boost::true_type)
|
||||
std::size_t n, std::true_type)
|
||||
{
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC < 1800
|
||||
if (!p) {
|
||||
@@ -296,7 +290,7 @@ public:
|
||||
: base(empty_init_t(), a) { }
|
||||
|
||||
void operator()(pointer p) {
|
||||
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), is_array<T>());
|
||||
detail::sp_alloc_clear(base::get(), p.ptr(), p.size(), std::is_array<T>());
|
||||
base::get().deallocate(p.ptr(), p.size());
|
||||
}
|
||||
};
|
||||
@@ -354,7 +348,7 @@ private:
|
||||
} /* detail */
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<!is_array<T>::value,
|
||||
inline typename std::enable_if<!std::is_array<T>::value,
|
||||
std::unique_ptr<T, alloc_deleter<T, A> > >::type
|
||||
allocate_unique(const A& alloc)
|
||||
{
|
||||
@@ -364,7 +358,7 @@ allocate_unique(const A& alloc)
|
||||
}
|
||||
|
||||
template<class T, class A, class... Args>
|
||||
inline typename enable_if_<!is_array<T>::value,
|
||||
inline typename std::enable_if<!std::is_array<T>::value,
|
||||
std::unique_ptr<T, alloc_deleter<T, A> > >::type
|
||||
allocate_unique(const A& alloc, Args&&... args)
|
||||
{
|
||||
@@ -374,9 +368,9 @@ allocate_unique(const A& alloc, Args&&... args)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<!is_array<T>::value,
|
||||
inline typename std::enable_if<!std::is_array<T>::value,
|
||||
std::unique_ptr<T, alloc_deleter<T, A> > >::type
|
||||
allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
|
||||
allocate_unique(const A& alloc, typename detail::sp_type_identity<T>::type&& value)
|
||||
{
|
||||
detail::sp_alloc_make<T, A> c(alloc, 1);
|
||||
boost::alloc_construct(c.state(), c.get(), std::move(value));
|
||||
@@ -384,7 +378,7 @@ allocate_unique(const A& alloc, typename type_identity<T>::type&& value)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<!is_array<T>::value,
|
||||
inline typename std::enable_if<!std::is_array<T>::value,
|
||||
std::unique_ptr<T, alloc_deleter<T, noinit_adaptor<A> > > >::type
|
||||
allocate_unique_noinit(const A& alloc)
|
||||
{
|
||||
@@ -392,7 +386,7 @@ allocate_unique_noinit(const A& alloc)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
std::unique_ptr<T, alloc_deleter<T, A> > >::type
|
||||
allocate_unique(const A& alloc, std::size_t size)
|
||||
{
|
||||
@@ -403,19 +397,19 @@ allocate_unique(const A& alloc, std::size_t size)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_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, extent<T>::value);
|
||||
detail::sp_alloc_make<T, A> c(alloc, std::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 enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_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)
|
||||
{
|
||||
@@ -423,7 +417,7 @@ allocate_unique_noinit(const A& alloc, std::size_t size)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_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)
|
||||
@@ -432,29 +426,29 @@ allocate_unique_noinit(const A& alloc)
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_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 remove_extent<T>::type& value)
|
||||
const typename std::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 remove_extent<T>::type>::value);
|
||||
detail::sp_alloc_size<typename std::remove_extent<T>::type>::value);
|
||||
return c.release();
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_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 remove_extent<T>::type& value)
|
||||
const typename std::remove_extent<T>::type& value)
|
||||
{
|
||||
detail::sp_alloc_make<T, A> c(alloc, extent<T>::value);
|
||||
detail::sp_alloc_make<T, A> c(alloc, std::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 remove_extent<T>::type>::value);
|
||||
detail::sp_alloc_size<typename std::remove_extent<T>::type>::value);
|
||||
return c.release();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
|
||||
#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 will be removed.")
|
||||
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 will be removed.")
|
||||
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 will be removed.")
|
||||
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
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
|
||||
#if defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
extern "C" void * lw_thread_routine( void * pv )
|
||||
extern "C" inline void * lw_thread_routine( void * pv )
|
||||
{
|
||||
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
@@ -115,7 +115,7 @@ extern "C" void * lw_thread_routine( void * pv )
|
||||
|
||||
#else
|
||||
|
||||
unsigned __stdcall lw_thread_routine( void * pv )
|
||||
inline unsigned __stdcall lw_thread_routine( void * pv )
|
||||
{
|
||||
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
|
||||
@@ -1,199 +1,63 @@
|
||||
#ifndef BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
||||
#define BOOST_SMART_PTR_DETAIL_QUICK_ALLOCATOR_HPP_INCLUDED
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
// 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
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
#include <boost/config/header_deprecated.hpp>
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
|
||||
//
|
||||
// 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
|
||||
BOOST_HEADER_DEPRECATED("std::allocator or std::pmr::synchronized_pool_resource")
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<unsigned size, unsigned align_> union freeblock
|
||||
template<class T> struct quick_allocator
|
||||
{
|
||||
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()
|
||||
static void* alloc()
|
||||
{
|
||||
static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm;
|
||||
static lightweight_mutex * pm = new( &fbm ) lightweight_mutex;
|
||||
return *pm;
|
||||
return std::allocator<T>().allocate( 1 );
|
||||
}
|
||||
|
||||
static lightweight_mutex * mutex_init;
|
||||
|
||||
#endif
|
||||
|
||||
static block * free;
|
||||
static block * page;
|
||||
static unsigned last;
|
||||
|
||||
static inline void * alloc()
|
||||
static void* alloc( std::size_t n )
|
||||
{
|
||||
#ifdef BOOST_HAS_THREADS
|
||||
lightweight_mutex::scoped_lock lock( mutex() );
|
||||
#endif
|
||||
if(block * x = free)
|
||||
if( n != sizeof(T) ) // class-specific delete called for a derived object
|
||||
{
|
||||
free = x->next;
|
||||
return x;
|
||||
return ::operator new( n );
|
||||
}
|
||||
else
|
||||
{
|
||||
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++];
|
||||
return alloc();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void * alloc(std::size_t n)
|
||||
static void dealloc( void* p )
|
||||
{
|
||||
if(n != size) // class-specific new called for a derived object
|
||||
if( p != 0 ) // 18.4.1.1/13
|
||||
{
|
||||
return ::operator new(n);
|
||||
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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
#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++];
|
||||
}
|
||||
dealloc( p );
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -55,13 +55,6 @@ 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
|
||||
@@ -112,32 +105,19 @@ 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)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
constexpr explicit shared_count( sp_counted_base * pi ) 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
|
||||
|
||||
@@ -165,9 +145,6 @@ public:
|
||||
}
|
||||
|
||||
template<class P, class D> shared_count( P p, D d ): pi_(0)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
@@ -195,9 +172,6 @@ public:
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -225,9 +199,6 @@ public:
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -272,9 +243,6 @@ public:
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -324,9 +292,6 @@ public:
|
||||
|
||||
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
|
||||
|
||||
@@ -344,9 +309,6 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@@ -367,9 +329,6 @@ public:
|
||||
|
||||
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;
|
||||
|
||||
@@ -391,23 +350,14 @@ public:
|
||||
~shared_count() /*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_)
|
||||
#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_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
r.pi_ = 0;
|
||||
}
|
||||
@@ -493,33 +443,20 @@ 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)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
weak_count(shared_count const & r) 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_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
{
|
||||
if(pi_ != 0) pi_->weak_add_ref();
|
||||
}
|
||||
@@ -527,9 +464,6 @@ public:
|
||||
// Move support
|
||||
|
||||
weak_count(weak_count && r) noexcept: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
{
|
||||
r.pi_ = 0;
|
||||
}
|
||||
@@ -537,9 +471,6 @@ public:
|
||||
~weak_count() /*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
|
||||
@@ -614,9 +545,6 @@ public:
|
||||
};
|
||||
|
||||
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() )
|
||||
{
|
||||
@@ -625,9 +553,6 @@ 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_ )
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
if( pi_ != 0 && !pi_->add_ref_lock() )
|
||||
{
|
||||
|
||||
@@ -18,33 +18,18 @@
|
||||
// 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/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
|
||||
{
|
||||
|
||||
@@ -76,16 +61,10 @@ 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
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
|
||||
#endif
|
||||
boost::checked_delete( px_ );
|
||||
}
|
||||
|
||||
@@ -103,34 +82,6 @@ public:
|
||||
{
|
||||
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
|
||||
};
|
||||
|
||||
template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public sp_counted_base
|
||||
@@ -176,34 +127,6 @@ public:
|
||||
{
|
||||
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
|
||||
|
||||
37
include/boost/smart_ptr/detail/sp_cxx20_constexpr.hpp
Normal file
37
include/boost/smart_ptr/detail/sp_cxx20_constexpr.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#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
|
||||
55
include/boost/smart_ptr/detail/sp_type_traits.hpp
Normal file
55
include/boost/smart_ptr/detail/sp_type_traits.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#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
|
||||
@@ -13,6 +13,7 @@
|
||||
// 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>
|
||||
@@ -53,29 +54,29 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
intrusive_ptr( T * p, bool add_ref = true ): px( p )
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr( T * p, bool add_ref = true ): px( p )
|
||||
{
|
||||
if( px != 0 && add_ref ) intrusive_ptr_add_ref( px );
|
||||
}
|
||||
|
||||
template<class U>
|
||||
intrusive_ptr( intrusive_ptr<U> const & rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty() )
|
||||
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() )
|
||||
: px( rhs.get() )
|
||||
{
|
||||
if( px != 0 ) intrusive_ptr_add_ref( px );
|
||||
}
|
||||
|
||||
intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px )
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr const & rhs): px( rhs.px )
|
||||
{
|
||||
if( px != 0 ) intrusive_ptr_add_ref( px );
|
||||
}
|
||||
|
||||
~intrusive_ptr()
|
||||
BOOST_SP_CXX20_CONSTEXPR ~intrusive_ptr()
|
||||
{
|
||||
if( px != 0 ) intrusive_ptr_release( px );
|
||||
}
|
||||
|
||||
template<class U> intrusive_ptr & operator=(intrusive_ptr<U> const & rhs)
|
||||
template<class U> BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr<U> const & rhs)
|
||||
{
|
||||
this_type(rhs).swap(*this);
|
||||
return *this;
|
||||
@@ -83,12 +84,12 @@ public:
|
||||
|
||||
// Move support
|
||||
|
||||
intrusive_ptr(intrusive_ptr && rhs) noexcept : px( rhs.px )
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr && rhs) noexcept : px( rhs.px )
|
||||
{
|
||||
rhs.px = 0;
|
||||
}
|
||||
|
||||
intrusive_ptr & operator=(intrusive_ptr && rhs) noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr && rhs) noexcept
|
||||
{
|
||||
this_type( static_cast< intrusive_ptr && >( rhs ) ).swap(*this);
|
||||
return *this;
|
||||
@@ -97,76 +98,76 @@ public:
|
||||
template<class U> friend class intrusive_ptr;
|
||||
|
||||
template<class U>
|
||||
intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
|
||||
: px( rhs.px )
|
||||
{
|
||||
rhs.px = 0;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
intrusive_ptr & operator=(intrusive_ptr<U> && rhs) noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr<U> && rhs) noexcept
|
||||
{
|
||||
this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
intrusive_ptr & operator=(intrusive_ptr const & rhs)
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(intrusive_ptr const & rhs)
|
||||
{
|
||||
this_type(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
intrusive_ptr & operator=(T * rhs)
|
||||
BOOST_SP_CXX20_CONSTEXPR intrusive_ptr & operator=(T * rhs)
|
||||
{
|
||||
this_type(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reset()
|
||||
BOOST_SP_CXX20_CONSTEXPR void reset()
|
||||
{
|
||||
this_type().swap( *this );
|
||||
}
|
||||
|
||||
void reset( T * rhs )
|
||||
BOOST_SP_CXX20_CONSTEXPR void reset( T * rhs )
|
||||
{
|
||||
this_type( rhs ).swap( *this );
|
||||
}
|
||||
|
||||
void reset( T * rhs, bool add_ref )
|
||||
BOOST_SP_CXX20_CONSTEXPR void reset( T * rhs, bool add_ref )
|
||||
{
|
||||
this_type( rhs, add_ref ).swap( *this );
|
||||
}
|
||||
|
||||
T * get() const noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR T * get() const noexcept
|
||||
{
|
||||
return px;
|
||||
}
|
||||
|
||||
T * detach() noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR T * detach() noexcept
|
||||
{
|
||||
T * ret = px;
|
||||
px = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
|
||||
BOOST_SP_CXX20_CONSTEXPR T & operator*() const BOOST_SP_NOEXCEPT_WITH_ASSERT
|
||||
{
|
||||
BOOST_ASSERT( px != 0 );
|
||||
return *px;
|
||||
}
|
||||
|
||||
T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
|
||||
BOOST_SP_CXX20_CONSTEXPR T * operator->() const BOOST_SP_NOEXCEPT_WITH_ASSERT
|
||||
{
|
||||
BOOST_ASSERT( px != 0 );
|
||||
return px;
|
||||
}
|
||||
|
||||
explicit operator bool () const noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR explicit operator bool () const noexcept
|
||||
{
|
||||
return px != 0;
|
||||
}
|
||||
|
||||
void swap(intrusive_ptr & rhs) noexcept
|
||||
BOOST_SP_CXX20_CONSTEXPR void swap(intrusive_ptr & rhs) noexcept
|
||||
{
|
||||
T * tmp = px;
|
||||
px = rhs.px;
|
||||
@@ -178,101 +179,101 @@ private:
|
||||
T * px;
|
||||
};
|
||||
|
||||
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
|
||||
{
|
||||
return a.get() == b.get();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept
|
||||
{
|
||||
return a.get() != b.get();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator==(intrusive_ptr<T> const & a, U * b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(intrusive_ptr<T> const & a, U * b) noexcept
|
||||
{
|
||||
return a.get() == b;
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(intrusive_ptr<T> const & a, U * b) noexcept
|
||||
{
|
||||
return a.get() != b;
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator==(T * a, intrusive_ptr<U> const & b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator==(T * a, intrusive_ptr<U> const & b) noexcept
|
||||
{
|
||||
return a == b.get();
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept
|
||||
{
|
||||
return a != b.get();
|
||||
}
|
||||
|
||||
template<class T> inline bool operator==( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator==( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
|
||||
{
|
||||
return p.get() == 0;
|
||||
}
|
||||
|
||||
template<class T> inline bool operator==( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator==( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
|
||||
{
|
||||
return p.get() == 0;
|
||||
}
|
||||
|
||||
template<class T> inline bool operator!=( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=( intrusive_ptr<T> const & p, std::nullptr_t ) noexcept
|
||||
{
|
||||
return p.get() != 0;
|
||||
}
|
||||
|
||||
template<class T> inline bool operator!=( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator!=( std::nullptr_t, intrusive_ptr<T> const & p ) noexcept
|
||||
{
|
||||
return p.get() != 0;
|
||||
}
|
||||
|
||||
template<class T> inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept
|
||||
{
|
||||
return std::less<T *>()(a.get(), b.get());
|
||||
}
|
||||
|
||||
template<class T> void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline void swap(intrusive_ptr<T> & lhs, intrusive_ptr<T> & rhs) noexcept
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
// mem_fn support
|
||||
|
||||
template<class T> T * get_pointer(intrusive_ptr<T> const & p) noexcept
|
||||
template<class T> BOOST_SP_CXX20_CONSTEXPR inline T * get_pointer(intrusive_ptr<T> const & p) noexcept
|
||||
{
|
||||
return p.get();
|
||||
}
|
||||
|
||||
// pointer casts
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & p)
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> static_pointer_cast(intrusive_ptr<U> const & p)
|
||||
{
|
||||
return static_cast<T *>(p.get());
|
||||
}
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> const_pointer_cast(intrusive_ptr<U> const & p)
|
||||
{
|
||||
return const_cast<T *>(p.get());
|
||||
}
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> dynamic_pointer_cast(intrusive_ptr<U> const & p)
|
||||
{
|
||||
return dynamic_cast<T *>(p.get());
|
||||
}
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> static_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> static_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
{
|
||||
return intrusive_ptr<T>( static_cast<T*>( p.detach() ), false );
|
||||
}
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> const_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> const_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
{
|
||||
return intrusive_ptr<T>( const_cast<T*>( p.detach() ), false );
|
||||
}
|
||||
|
||||
template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
template<class T, class U> BOOST_SP_CXX20_CONSTEXPR inline intrusive_ptr<T> dynamic_pointer_cast( intrusive_ptr<U> && p ) noexcept
|
||||
{
|
||||
T * p2 = dynamic_cast<T*>( p.get() );
|
||||
|
||||
@@ -285,7 +286,7 @@ template<class T, class U> intrusive_ptr<T> dynamic_pointer_cast( intrusive_ptr<
|
||||
|
||||
// operator<<
|
||||
|
||||
template<class Y> std::ostream & operator<< (std::ostream & os, intrusive_ptr<Y> const & p)
|
||||
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, intrusive_ptr<Y> const & p)
|
||||
{
|
||||
os << p.get();
|
||||
return os;
|
||||
|
||||
@@ -11,11 +11,13 @@ 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 enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared()
|
||||
{
|
||||
@@ -24,16 +26,16 @@ make_local_shared()
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(const typename remove_extent<T>::type& value)
|
||||
make_local_shared(const typename std::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 enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(std::size_t size)
|
||||
{
|
||||
@@ -42,17 +44,17 @@ make_local_shared(std::size_t size)
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(std::size_t size,
|
||||
const typename remove_extent<T>::type& value)
|
||||
const typename std::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 enable_if_<is_bounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared_noinit()
|
||||
{
|
||||
@@ -61,7 +63,7 @@ make_local_shared_noinit()
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared_noinit(std::size_t size)
|
||||
{
|
||||
|
||||
@@ -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), ::boost::alignment_of<T>::value>::type storage_type;
|
||||
typedef typename sp_aligned_storage<sizeof(T), std::alignment_of<T>::value>::type storage_type;
|
||||
|
||||
storage_type storage_;
|
||||
A a_;
|
||||
@@ -155,13 +155,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 boost::remove_const<T>::type T2;
|
||||
typedef typename std::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 boost::remove_const<T>::type T2;
|
||||
typedef typename std::remove_const<T>::type T2;
|
||||
return boost::allocate_shared_noinit<T2>( std::allocator<T2>() );
|
||||
}
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@ 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 enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared()
|
||||
{
|
||||
return boost::allocate_shared<T>(boost::default_allocator<typename
|
||||
@@ -22,15 +24,15 @@ make_shared()
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared(const typename remove_extent<T>::type& value)
|
||||
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)
|
||||
{
|
||||
return boost::allocate_shared<T>(boost::default_allocator<typename
|
||||
detail::sp_array_element<T>::type>(), value);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared(std::size_t size)
|
||||
{
|
||||
return boost::allocate_shared<T>(boost::default_allocator<typename
|
||||
@@ -38,15 +40,15 @@ make_shared(std::size_t size)
|
||||
}
|
||||
|
||||
template<class T>
|
||||
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)
|
||||
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)
|
||||
{
|
||||
return boost::allocate_shared<T>(boost::default_allocator<typename
|
||||
detail::sp_array_element<T>::type>(), size, value);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared_noinit()
|
||||
{
|
||||
return boost::allocate_shared_noinit<T>(boost::default_allocator<typename
|
||||
@@ -54,7 +56,7 @@ make_shared_noinit()
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
inline typename std::enable_if<detail::sp_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
|
||||
|
||||
@@ -12,16 +12,15 @@
|
||||
// See http://www.boost.org/libs/smart_ptr/ for documentation.
|
||||
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#include <boost/type_traits/type_with_alignment.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@@ -30,7 +29,7 @@ template< std::size_t N, std::size_t A > struct sp_aligned_storage
|
||||
union type
|
||||
{
|
||||
char data_[ N ];
|
||||
typename boost::type_with_alignment< A >::type align_;
|
||||
typename sp_type_with_alignment< A >::type align_;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -38,7 +37,7 @@ template< class T > class sp_ms_deleter
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
|
||||
typedef typename sp_aligned_storage< sizeof( T ), std::alignment_of< T >::value >::type storage_type;
|
||||
|
||||
bool initialized_;
|
||||
storage_type storage_;
|
||||
@@ -109,7 +108,7 @@ template< class T, class A > class sp_as_deleter
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
|
||||
typedef typename sp_aligned_storage< sizeof( T ), std::alignment_of< T >::value >::type storage_type;
|
||||
|
||||
storage_type storage_;
|
||||
A a_;
|
||||
|
||||
@@ -8,58 +8,55 @@ 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/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 <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique()
|
||||
{
|
||||
return std::unique_ptr<T>(new T());
|
||||
}
|
||||
|
||||
template<class T, class... Args>
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique(typename remove_reference<T>::type&& value)
|
||||
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique(typename std::remove_reference<T>::type&& value)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::move(value)));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique_noinit()
|
||||
{
|
||||
return std::unique_ptr<T>(new T);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
std::unique_ptr<T> >::type
|
||||
make_unique(std::size_t size)
|
||||
{
|
||||
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]());
|
||||
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
|
||||
std::unique_ptr<T> >::type
|
||||
make_unique_noinit(std::size_t size)
|
||||
{
|
||||
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]);
|
||||
return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
@@ -22,15 +22,6 @@
|
||||
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.
|
||||
@@ -55,16 +46,10 @@ public:
|
||||
|
||||
explicit scoped_array( T * p = 0 ) noexcept : px( p )
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_array_constructor_hook( px );
|
||||
#endif
|
||||
}
|
||||
|
||||
~scoped_array() noexcept
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_array_destructor_hook( px );
|
||||
#endif
|
||||
boost::checked_array_delete( px );
|
||||
}
|
||||
|
||||
|
||||
@@ -31,15 +31,6 @@
|
||||
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;
|
||||
@@ -65,27 +56,18 @@ public:
|
||||
|
||||
explicit scoped_ptr( T * p = 0 ) 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() )
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_scalar_constructor_hook( px );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
~scoped_ptr() noexcept
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_scalar_destructor_hook( px );
|
||||
#endif
|
||||
boost::checked_delete( px );
|
||||
}
|
||||
|
||||
|
||||
@@ -775,7 +775,7 @@ template<class T> inline typename shared_ptr<T>::element_type * get_pointer(shar
|
||||
|
||||
// operator<<
|
||||
|
||||
template<class Y> std::ostream & operator<< (std::ostream & os, shared_ptr<Y> const & p)
|
||||
template<class E, class T, class Y> std::basic_ostream<E, T> & operator<< (std::basic_ostream<E, T> & os, shared_ptr<Y> const & p)
|
||||
{
|
||||
os << p.get();
|
||||
return os;
|
||||
|
||||
58
test/Jamfile
58
test/Jamfile
@@ -14,15 +14,20 @@ 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
|
||||
;
|
||||
|
||||
local cnhash = <library>/boost/container_hash//boost_container_hash ;
|
||||
|
||||
# quick test (for CI)
|
||||
run quick.cpp ;
|
||||
|
||||
@@ -79,8 +84,7 @@ run shared_ptr_convertible_test.cpp ;
|
||||
run wp_convertible_test.cpp ;
|
||||
run ip_convertible_test.cpp ;
|
||||
run allocate_shared_test.cpp ;
|
||||
run sp_atomic_test.cpp
|
||||
: : : <library>/boost/atomic//boost_atomic ;
|
||||
run sp_atomic_test.cpp ;
|
||||
run esft_void_test.cpp ;
|
||||
run esft_second_ptr_test.cpp ;
|
||||
run make_shared_esft_test.cpp ;
|
||||
@@ -95,11 +99,9 @@ compile-fail auto_ptr_lv_fail.cpp ;
|
||||
run atomic_count_test2.cpp ;
|
||||
run sp_typeinfo_test.cpp ;
|
||||
compile make_shared_fp_test.cpp ;
|
||||
run sp_hash_test.cpp
|
||||
: : : $(cnhash) ;
|
||||
run sp_hash_test.cpp ;
|
||||
run get_deleter_array_test.cpp ;
|
||||
run ip_hash_test.cpp
|
||||
: : : $(cnhash) ;
|
||||
run ip_hash_test.cpp ;
|
||||
run owner_less_test.cpp ;
|
||||
run sp_unique_ptr_test.cpp ;
|
||||
run sp_array_test.cpp ;
|
||||
@@ -216,10 +218,8 @@ run weak_from_this_test2.cpp ;
|
||||
|
||||
run sp_bml_unique_ptr_test.cpp ;
|
||||
|
||||
run sp_hash_test2.cpp
|
||||
: : : $(cnhash) ;
|
||||
run sp_hash_test3.cpp
|
||||
: : : $(cnhash) ;
|
||||
run sp_hash_test2.cpp ;
|
||||
run sp_hash_test3.cpp ;
|
||||
|
||||
run pointer_cast_test2.cpp ;
|
||||
|
||||
@@ -241,11 +241,11 @@ compile make_shared_msvc_test.cpp ;
|
||||
|
||||
compile lwm_win32_cs_test.cpp ;
|
||||
|
||||
run atomic_sp_test.cpp
|
||||
: : : <library>/boost/atomic//boost_atomic ;
|
||||
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 ;
|
||||
|
||||
@@ -388,33 +388,29 @@ run owner_less_test2.cpp ;
|
||||
run ip_hash_test2.cpp ;
|
||||
run sp_hash_test4.cpp ;
|
||||
|
||||
run lsp_hash_test.cpp
|
||||
: : : $(cnhash) ;
|
||||
run lsp_hash_test.cpp ;
|
||||
run lsp_hash_test2.cpp ;
|
||||
|
||||
local MT = <threading>multi <library>/boost/bind//boost_bind ;
|
||||
|
||||
run atomic_count_mt_test.cpp
|
||||
: : : $(MT) ;
|
||||
: : : <threading>multi ;
|
||||
|
||||
run spinlock_mt_test.cpp
|
||||
: : : $(MT) ;
|
||||
: : : <threading>multi ;
|
||||
|
||||
run spinlock_pool_mt_test.cpp
|
||||
: : : $(MT) ;
|
||||
: : : <threading>multi ;
|
||||
|
||||
run shared_ptr_mt_test.cpp
|
||||
: : : $(MT) ;
|
||||
: : : <threading>multi ;
|
||||
|
||||
run weak_ptr_mt_test.cpp
|
||||
: : : $(MT) ;
|
||||
: : : <threading>multi ;
|
||||
|
||||
compile sp_report_implementation.cpp ;
|
||||
|
||||
run sp_owner_hash_value_test.cpp ;
|
||||
|
||||
run wp_hash_test.cpp
|
||||
: : : $(cnhash) ;
|
||||
run wp_hash_test.cpp ;
|
||||
run wp_hash_test2.cpp ;
|
||||
|
||||
run wp_unordered_test.cpp ;
|
||||
@@ -424,3 +420,15 @@ 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 ;
|
||||
|
||||
@@ -8,9 +8,9 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
@@ -87,7 +87,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
@@ -95,7 +95,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
@@ -103,7 +103,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
@@ -111,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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
@@ -119,7 +119,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
@@ -127,7 +127,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
@@ -135,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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
@@ -143,7 +143,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
@@ -151,7 +151,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> other = result;
|
||||
result.reset();
|
||||
@@ -163,7 +163,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -175,7 +175,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -187,7 +187,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[2][2]> other = result;
|
||||
result.reset();
|
||||
@@ -199,7 +199,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[]> other = result;
|
||||
result.reset();
|
||||
@@ -211,7 +211,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -224,7 +224,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -236,7 +236,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
|
||||
@@ -8,9 +8,9 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
@@ -87,7 +87,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -98,7 +98,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -109,7 +109,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -121,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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -133,7 +133,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -144,7 +144,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -155,7 +155,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -167,7 +167,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -179,7 +179,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = result;
|
||||
result.reset();
|
||||
@@ -191,7 +191,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = result;
|
||||
result.reset();
|
||||
@@ -203,7 +203,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -214,7 +214,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -225,7 +225,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -236,7 +236,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -247,7 +247,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -258,7 +258,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
|
||||
@@ -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 <boost/type_traits/alignment_of.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
|
||||
@@ -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 <boost/type_traits/alignment_of.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
|
||||
133
test/ip_constexpr_test.cpp
Normal file
133
test/ip_constexpr_test.cpp
Normal file
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// ip_constexpr_test.cpp
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
#ifndef BOOST_SP_NO_CXX20_CONSTEXPR
|
||||
|
||||
struct dummy {
|
||||
// no-ops, so safe on pointers to static constexpr variables
|
||||
friend constexpr void intrusive_ptr_add_ref(const dummy *) {}
|
||||
friend constexpr void intrusive_ptr_release(const dummy *) {}
|
||||
};
|
||||
static constexpr dummy d;
|
||||
|
||||
struct subdummy : dummy {};
|
||||
|
||||
// Test that basic operations work at compile time.
|
||||
static_assert(bool(boost::intrusive_ptr<const dummy>(&d)));
|
||||
static_assert(!bool(boost::intrusive_ptr<dummy>(nullptr)));
|
||||
static_assert(!bool(boost::intrusive_ptr<dummy>()));
|
||||
static_assert(!bool(boost::intrusive_ptr<dummy>(boost::intrusive_ptr<subdummy>())));
|
||||
static_assert(&*boost::intrusive_ptr<const dummy>(&d) == &d);
|
||||
static_assert(boost::intrusive_ptr<const dummy>(&d).operator->() == &d);
|
||||
static_assert(boost::intrusive_ptr<dummy>() == nullptr);
|
||||
static_assert(boost::intrusive_ptr<dummy>() == boost::intrusive_ptr<dummy>(nullptr));
|
||||
static_assert(boost::intrusive_ptr<dummy>() != boost::intrusive_ptr<const dummy>(&d));
|
||||
static_assert(boost::intrusive_ptr<const dummy>(&d) != nullptr);
|
||||
static_assert(boost::intrusive_ptr<const dummy>(&d) == boost::intrusive_ptr<const dummy>(&d));
|
||||
static_assert(boost::intrusive_ptr<const dummy>(&d) == boost::intrusive_ptr<const dummy>(&d).get());
|
||||
static_assert(boost::intrusive_ptr<const dummy>(&d) == boost::intrusive_ptr<const dummy>(&d).detach());
|
||||
static_assert(!(boost::intrusive_ptr<const dummy>(&d) < boost::intrusive_ptr<const dummy>(&d)));
|
||||
static_assert(boost::get_pointer(boost::intrusive_ptr<const dummy>(&d)) == &d);
|
||||
static_assert(boost::static_pointer_cast<const dummy>( boost::intrusive_ptr<const dummy>(&d)) == &d);
|
||||
static_assert(boost::const_pointer_cast<const dummy>( boost::intrusive_ptr<const dummy>(&d)) == &d);
|
||||
static_assert(boost::dynamic_pointer_cast<const dummy>( boost::intrusive_ptr<const dummy>(&d)) == &d);
|
||||
|
||||
constexpr auto lvalue = boost::intrusive_ptr<const dummy>(&d);
|
||||
constexpr auto lvalue_convertible = boost::intrusive_ptr<const subdummy>();
|
||||
static_assert(boost::intrusive_ptr<const dummy>(lvalue) == &d);
|
||||
static_assert(!boost::intrusive_ptr<const dummy>(lvalue_convertible));
|
||||
static_assert(boost::static_pointer_cast<const dummy>(lvalue) == &d);
|
||||
static_assert(boost::const_pointer_cast<const dummy>(lvalue) == &d);
|
||||
static_assert(boost::dynamic_pointer_cast<const dummy>(lvalue) == &d);
|
||||
|
||||
// Works in places that static_assert doesn't, like expressions with
|
||||
// non-constexpr variables in constexpr functions.
|
||||
template <typename T> constexpr void semi_static_assert(T b) {
|
||||
if (!b)
|
||||
throw "assertion failed"; // Not constexpr so fails compile.
|
||||
}
|
||||
|
||||
constexpr bool test_swap() {
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
auto p2 = boost::intrusive_ptr<const dummy>();
|
||||
swap(p1, p2);
|
||||
semi_static_assert(!p1 && p2);
|
||||
p1.swap(p2);
|
||||
semi_static_assert(p1 && !p2);
|
||||
return true;
|
||||
}
|
||||
static_assert(test_swap());
|
||||
|
||||
constexpr bool test_reset_assign() {
|
||||
// Test assignments resulting in nullptr
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1.reset();
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1.reset(nullptr);
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1 = nullptr;
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1 = boost::intrusive_ptr<const dummy>();
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1 = boost::intrusive_ptr<subdummy>();
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
p1 = lvalue_convertible;
|
||||
semi_static_assert(!p1);
|
||||
}
|
||||
|
||||
// Test assignments resulting in &d
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>();
|
||||
p1.reset(&d);
|
||||
semi_static_assert(p1 == &d);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>();
|
||||
p1.reset(&d, true);
|
||||
semi_static_assert(p1 == &d);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>();
|
||||
p1 = boost::intrusive_ptr<const dummy>(&d);
|
||||
semi_static_assert(p1 == &d);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>();
|
||||
p1 = lvalue;
|
||||
semi_static_assert(p1 == &d);
|
||||
}
|
||||
{
|
||||
auto p1 = boost::intrusive_ptr<const dummy>();
|
||||
p1 = &d;
|
||||
semi_static_assert(p1 == &d);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static_assert(test_reset_assign());
|
||||
|
||||
#endif
|
||||
75
test/ip_ostream_test.cpp
Normal file
75
test/ip_ostream_test.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright 2011, 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
class base
|
||||
{
|
||||
private:
|
||||
|
||||
int use_count_;
|
||||
|
||||
base(base const &);
|
||||
base & operator=(base const &);
|
||||
|
||||
protected:
|
||||
|
||||
base(): use_count_(0)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~base()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
long use_count() const
|
||||
{
|
||||
return use_count_;
|
||||
}
|
||||
|
||||
inline friend void intrusive_ptr_add_ref(base * p)
|
||||
{
|
||||
++p->use_count_;
|
||||
}
|
||||
|
||||
inline friend void intrusive_ptr_release(base * p)
|
||||
{
|
||||
if(--p->use_count_ == 0) delete p;
|
||||
}
|
||||
};
|
||||
|
||||
struct X: public base
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> std::string to_string( T const& t )
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template<class T> std::wstring to_wstring( T const& t )
|
||||
{
|
||||
std::wostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::intrusive_ptr<X> p1, p2( new X );
|
||||
|
||||
BOOST_TEST_EQ( to_string( p1 ), to_string( p1.get() ) );
|
||||
BOOST_TEST_EQ( to_string( p2 ), to_string( p2.get() ) );
|
||||
|
||||
BOOST_TEST( to_wstring( p1 ) == to_wstring( p1.get() ) );
|
||||
BOOST_TEST( to_wstring( p2 ) == to_wstring( p2.get() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
//
|
||||
|
||||
@@ -26,7 +26,7 @@ class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
using std::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
//
|
||||
|
||||
@@ -26,7 +26,7 @@ class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
using std::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
|
||||
34
test/lsp_ostream_test.cpp
Normal file
34
test/lsp_ostream_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
template<class T> std::string to_string( T const& t )
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template<class T> std::wstring to_wstring( T const& t )
|
||||
{
|
||||
std::wostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::local_shared_ptr<int> p1, p2( new int );
|
||||
|
||||
BOOST_TEST_EQ( to_string( p1 ), to_string( p1.get() ) );
|
||||
BOOST_TEST_EQ( to_string( p2 ), to_string( p2.get() ) );
|
||||
|
||||
BOOST_TEST( to_wstring( p1 ) == to_wstring( p1.get() ) );
|
||||
BOOST_TEST( to_wstring( p2 ) == to_wstring( p2.get() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -8,9 +8,9 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -50,7 +50,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
@@ -58,7 +58,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
@@ -66,7 +66,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
@@ -74,7 +74,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
@@ -82,7 +82,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
@@ -90,7 +90,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
@@ -98,7 +98,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
@@ -106,7 +106,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
@@ -114,7 +114,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> other = result;
|
||||
result.reset();
|
||||
@@ -126,7 +126,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -138,7 +138,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -150,7 +150,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[2][2]> other = result;
|
||||
result.reset();
|
||||
@@ -162,7 +162,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[]> other = result;
|
||||
result.reset();
|
||||
@@ -174,7 +174,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -186,7 +186,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -198,7 +198,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
|
||||
@@ -8,9 +8,9 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -50,7 +50,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -61,7 +61,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -72,7 +72,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -84,7 +84,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -96,7 +96,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -107,7 +107,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -118,7 +118,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -130,7 +130,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -142,7 +142,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = result;
|
||||
result.reset();
|
||||
@@ -154,7 +154,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = result;
|
||||
result.reset();
|
||||
@@ -166,7 +166,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -177,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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -188,7 +188,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -199,7 +199,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -210,7 +210,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -221,7 +221,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
|
||||
@@ -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 <boost/type_traits/alignment_of.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -49,7 +49,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[3]> result =
|
||||
@@ -57,7 +57,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[][2]> result =
|
||||
@@ -65,7 +65,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[2][2]> result =
|
||||
@@ -73,7 +73,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[]> result =
|
||||
@@ -81,7 +81,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[3]> result =
|
||||
@@ -89,7 +89,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[][2]> result =
|
||||
@@ -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(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[2][2]> result =
|
||||
@@ -105,7 +105,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[]> result =
|
||||
@@ -113,7 +113,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> other = result;
|
||||
result.reset();
|
||||
@@ -125,7 +125,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -137,7 +137,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -149,7 +149,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[2][2]> other = result;
|
||||
result.reset();
|
||||
@@ -161,7 +161,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[]> other = result;
|
||||
result.reset();
|
||||
@@ -173,7 +173,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[3]> other = result;
|
||||
result.reset();
|
||||
@@ -185,7 +185,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[][2]> other = result;
|
||||
result.reset();
|
||||
@@ -197,7 +197,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
|
||||
@@ -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 <boost/type_traits/alignment_of.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
class type {
|
||||
public:
|
||||
@@ -49,7 +49,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -60,7 +60,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -71,7 +71,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -83,7 +83,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -95,7 +95,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -106,7 +106,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
@@ -117,7 +117,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -129,7 +129,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<int>::value));
|
||||
std::alignment_of<int>::value));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -141,7 +141,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = result;
|
||||
result.reset();
|
||||
@@ -153,7 +153,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = result;
|
||||
result.reset();
|
||||
@@ -165,7 +165,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -176,7 +176,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -187,7 +187,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -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(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -209,7 +209,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
@@ -220,7 +220,7 @@ int main()
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
boost::alignment_of<type>::value));
|
||||
std::alignment_of<type>::value));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
|
||||
99
test/quick_allocator_test.cpp
Normal file
99
test/quick_allocator_test.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/quick_allocator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cstring>
|
||||
|
||||
// The interface of quick_allocator has never been documented,
|
||||
// but in can be inferred from the source code to be
|
||||
//
|
||||
// template<class T> struct quick_allocator
|
||||
// {
|
||||
// // allocate memory for an object of type T
|
||||
// static void* alloc();
|
||||
//
|
||||
// // deallocate the memory returned from alloc()
|
||||
// // if p == 0, no effect
|
||||
// static void dealloc( void* p );
|
||||
//
|
||||
// // if n == sizeof(T), returns alloc()
|
||||
// // otherwise, allocates a memory block of size n
|
||||
// static void* alloc( std::size_t n );
|
||||
//
|
||||
// // deallocate the memory returned from alloc( n )
|
||||
// // if p == 0, no effect
|
||||
// static void dealloc( void* p, std::size_t n );
|
||||
// };
|
||||
|
||||
struct X
|
||||
{
|
||||
int data;
|
||||
};
|
||||
|
||||
struct Y: public X
|
||||
{
|
||||
int data2;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::quick_allocator;
|
||||
|
||||
void* p = quick_allocator<Y>::alloc();
|
||||
std::memset( p, 0xAA, sizeof(Y) );
|
||||
|
||||
{
|
||||
void* p1 = quick_allocator<X>::alloc();
|
||||
std::memset( p1, 0xCC, sizeof(X) );
|
||||
|
||||
void* p2 = quick_allocator<X>::alloc();
|
||||
std::memset( p2, 0xDD, sizeof(X) );
|
||||
|
||||
BOOST_TEST_NE( p1, p2 );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p1 ), 0xCC );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( 0 );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p1 ), 0xCC );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( p1 );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( p2 );
|
||||
}
|
||||
|
||||
{
|
||||
void* p1 = quick_allocator<X>::alloc( sizeof(X) );
|
||||
std::memset( p1, 0xCC, sizeof(X) );
|
||||
|
||||
void* p2 = quick_allocator<X>::alloc( sizeof(Y) );
|
||||
std::memset( p2, 0xDD, sizeof(Y) );
|
||||
|
||||
BOOST_TEST_NE( p1, p2 );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p1 ), 0xCC );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( 0, sizeof(X) );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p1 ), 0xCC );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( p1, sizeof(X) );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( 0, sizeof(Y) );
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p2 ), 0xDD );
|
||||
|
||||
quick_allocator<X>::dealloc( p2, sizeof(Y) );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p ), 0xAA );
|
||||
quick_allocator<Y>::dealloc( 0 );
|
||||
|
||||
BOOST_TEST_EQ( *static_cast<unsigned char*>( p ), 0xAA );
|
||||
quick_allocator<Y>::dealloc( p );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
|
||||
void * operator new(std::size_t)
|
||||
{
|
||||
return std::allocator<X>().allocate(1, static_cast<X*>(0));
|
||||
return std::allocator<X>().allocate(1);
|
||||
}
|
||||
|
||||
void operator delete(void * p)
|
||||
@@ -122,18 +122,6 @@ int main()
|
||||
std::cout << "BOOST_HAS_THREADS: (not defined)\n";
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SP_USE_STD_ALLOCATOR)
|
||||
std::cout << "BOOST_SP_USE_STD_ALLOCATOR: (defined)\n";
|
||||
#else
|
||||
std::cout << "BOOST_SP_USE_STD_ALLOCATOR: (not defined)\n";
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
|
||||
std::cout << "BOOST_SP_USE_QUICK_ALLOCATOR: (defined)\n";
|
||||
#else
|
||||
std::cout << "BOOST_SP_USE_QUICK_ALLOCATOR: (not defined)\n";
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_QA_PAGE_SIZE)
|
||||
std::cout << "BOOST_QA_PAGE_SIZE: " << BOOST_QA_PAGE_SIZE << "\n";
|
||||
#else
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/move/unique_ptr.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
struct X: public boost::enable_shared_from_this< X >
|
||||
{
|
||||
@@ -88,7 +88,7 @@ template<class U, class T, class D> static void test_null_unique_ptr( boost::mov
|
||||
BOOST_TEST( sp.get() == 0 );
|
||||
BOOST_TEST( sp.use_count() == 0 );
|
||||
|
||||
sp.reset( new T, typename boost::remove_reference<D>::type() );
|
||||
sp.reset( new T, typename std::remove_reference<D>::type() );
|
||||
|
||||
BOOST_TEST( sp.get() != 0 );
|
||||
BOOST_TEST( sp.use_count() == 1 );
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
//
|
||||
|
||||
@@ -25,7 +25,7 @@ class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
using std::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
|
||||
27
test/sp_is_bounded_array_test.cpp
Normal file
27
test/sp_is_bounded_array_test.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_is_bounded_array;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<int> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<X> ));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<int[]> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_bounded_array<X[]> ));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<int[1]> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<int[7]> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<X[1]> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_bounded_array<X[7]> ));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
27
test/sp_is_unbounded_array_test.cpp
Normal file
27
test/sp_is_unbounded_array_test.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_is_unbounded_array;
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<void> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<int> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<X> ));
|
||||
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_unbounded_array<int[]> ));
|
||||
BOOST_TEST_TRAIT_TRUE(( sp_is_unbounded_array<X[]> ));
|
||||
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<int[1]> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<int[7]> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<X[1]> ));
|
||||
BOOST_TEST_TRAIT_FALSE(( sp_is_unbounded_array<X[7]> ));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
34
test/sp_ostream_test.cpp
Normal file
34
test/sp_ostream_test.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
template<class T> std::string to_string( T const& t )
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template<class T> std::wstring to_wstring( T const& t )
|
||||
{
|
||||
std::wostringstream os;
|
||||
os << t;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::shared_ptr<int> p1, p2( new int );
|
||||
|
||||
BOOST_TEST_EQ( to_string( p1 ), to_string( p1.get() ) );
|
||||
BOOST_TEST_EQ( to_string( p2 ), to_string( p2.get() ) );
|
||||
|
||||
BOOST_TEST( to_wstring( p1 ) == to_wstring( p1.get() ) );
|
||||
BOOST_TEST( to_wstring( p2 ) == to_wstring( p2.get() ) );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
31
test/sp_type_identity_test.cpp
Normal file
31
test/sp_type_identity_test.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/core/lightweight_test_trait.hpp>
|
||||
|
||||
struct X;
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_type_identity;
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void>::type, void );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int>::type, int );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X>::type, X );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void const>::type, void const );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int const>::type, int const );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X const>::type, X const );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<void(int, X)>::type, void(int, X) );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int[]>::type, int[] );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X[]>::type, X[] );
|
||||
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<int[1]>::type, int[1] );
|
||||
BOOST_TEST_TRAIT_SAME( sp_type_identity<X[2]>::type, X[2] );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
18
test/sp_type_with_alignment_test.cpp
Normal file
18
test/sp_type_with_alignment_test.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::detail::sp_type_with_alignment;
|
||||
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<1>::type ), 1 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<2>::type ), 2 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<4>::type ), 4 );
|
||||
BOOST_TEST_EQ( alignof( sp_type_with_alignment<8>::type ), 8 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
@@ -11,9 +11,9 @@
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
struct X: public boost::enable_shared_from_this< X >
|
||||
{
|
||||
@@ -87,7 +87,7 @@ template<class U, class T, class D> static void test_null_unique_ptr( std::uniqu
|
||||
BOOST_TEST( sp.get() == 0 );
|
||||
BOOST_TEST( sp.use_count() == 0 );
|
||||
|
||||
sp.reset( new T, typename boost::remove_reference<D>::type() );
|
||||
sp.reset( new T, typename std::remove_reference<D>::type() );
|
||||
|
||||
BOOST_TEST( sp.get() != 0 );
|
||||
BOOST_TEST( sp.use_count() == 1 );
|
||||
|
||||
Reference in New Issue
Block a user