forked from boostorg/smart_ptr
Compare commits
35 Commits
boost-1.74
...
develop
Author | SHA1 | Date | |
---|---|---|---|
59b5b17e81 | |||
f2ab3b21f0 | |||
e04196b6a1 | |||
95eaa2d7c3 | |||
2e31d0d633 | |||
b8cb132ab4 | |||
f4d7116241 | |||
f2cc84a23c | |||
f12a33813d | |||
cfde4f7407 | |||
b8d340b495 | |||
6716193d9c | |||
8f40bff2f6 | |||
1ef8f4e72d | |||
f651a49d96 | |||
598314b8e1 | |||
72221d1da0 | |||
2cbeb5b185 | |||
67e657c228 | |||
eba3cf92e7 | |||
8340a13539 | |||
098d0f4ce3 | |||
fec5fb97c8 | |||
b52d7548b3 | |||
594c7485a5 | |||
d751041fb9 | |||
d41546ddce | |||
f3424e74e8 | |||
0eee7efd54 | |||
dc2a127369 | |||
42575a0e51 | |||
64b2eac868 | |||
856ed108e8 | |||
678a544d27 | |||
f1b06df6f4 |
383
.github/workflows/ci.yml
vendored
Normal file
383
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,383 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
- feature/**
|
||||
|
||||
env:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
|
||||
jobs:
|
||||
posix:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: gcc-4.8
|
||||
cxxstd: "03,11"
|
||||
os: ubuntu-18.04
|
||||
install: g++-4.8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-5
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install: g++-5-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-6
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install: g++-6-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: g++-7-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-8
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-18.04
|
||||
install: g++-8-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-9-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: g++-10-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-11
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
install: g++-11-multilib
|
||||
address-model: 32,64
|
||||
- toolset: gcc-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install: g++-12-multilib
|
||||
address-model: 32,64
|
||||
- toolset: clang
|
||||
compiler: clang++-3.9
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install: clang-3.9
|
||||
- toolset: clang
|
||||
compiler: clang++-4.0
|
||||
cxxstd: "03,11,14"
|
||||
os: ubuntu-18.04
|
||||
install: clang-4.0
|
||||
- toolset: clang
|
||||
compiler: clang++-5.0
|
||||
cxxstd: "03,11,14,1z"
|
||||
os: ubuntu-18.04
|
||||
install: clang-5.0
|
||||
- toolset: clang
|
||||
compiler: clang++-6.0
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-6.0
|
||||
- toolset: clang
|
||||
compiler: clang++-7
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-18.04
|
||||
install: clang-7
|
||||
- toolset: clang
|
||||
compiler: clang++-8
|
||||
cxxstd: "03,11,14,17"
|
||||
os: ubuntu-20.04
|
||||
install: clang-8
|
||||
- toolset: clang
|
||||
compiler: clang++-9
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
install: clang-9
|
||||
- toolset: clang
|
||||
compiler: clang++-10
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-11
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-12
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-20.04
|
||||
- toolset: clang
|
||||
compiler: clang++-13
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install: clang-13
|
||||
- toolset: clang
|
||||
compiler: clang++-14
|
||||
cxxstd: "03,11,14,17,20"
|
||||
os: ubuntu-22.04
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
./bootstrap.sh
|
||||
./b2 -d0 headers
|
||||
|
||||
- name: Create user-config.jam
|
||||
if: matrix.compiler
|
||||
run: |
|
||||
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root
|
||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
|
||||
|
||||
windows:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- toolset: msvc-14.0
|
||||
cxxstd: 14,latest
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.2
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2019
|
||||
- toolset: msvc-14.3
|
||||
cxxstd: "14,17,20,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: clang-win
|
||||
cxxstd: "14,17,latest"
|
||||
addrmd: 32,64
|
||||
os: windows-2022
|
||||
- toolset: gcc
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
addrmd: 64
|
||||
os: windows-2019
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Boost
|
||||
shell: cmd
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
|
||||
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
|
||||
echo LIBRARY: %LIBRARY%
|
||||
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
|
||||
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
|
||||
echo GITHUB_REF: %GITHUB_REF%
|
||||
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
|
||||
set BOOST_BRANCH=develop
|
||||
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
|
||||
echo BOOST_BRANCH: %BOOST_BRANCH%
|
||||
cd ..
|
||||
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
|
||||
cmd /c bootstrap
|
||||
b2 -d0 headers
|
||||
|
||||
- name: Run tests
|
||||
shell: cmd
|
||||
run: |
|
||||
cd ../boost-root
|
||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release embed-manifest-via=linker
|
||||
|
||||
posix-cmake-subdir:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Use library with add_subdirectory
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
|
||||
mkdir __build__ && cd __build__
|
||||
cmake ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-install:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target install
|
||||
|
||||
- name: Use the installed library
|
||||
run: |
|
||||
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
|
||||
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
|
||||
cmake --build .
|
||||
ctest --output-on-failure --no-tests=error
|
||||
|
||||
posix-cmake-test:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install packages
|
||||
if: matrix.install
|
||||
run: sudo apt install ${{matrix.install}}
|
||||
|
||||
- name: Setup Boost
|
||||
run: |
|
||||
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
|
||||
LIBRARY=${GITHUB_REPOSITORY#*/}
|
||||
echo LIBRARY: $LIBRARY
|
||||
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
|
||||
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
|
||||
echo GITHUB_REF: $GITHUB_REF
|
||||
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
|
||||
REF=${REF#refs/heads/}
|
||||
echo REF: $REF
|
||||
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
|
||||
echo BOOST_BRANCH: $BOOST_BRANCH
|
||||
cd ..
|
||||
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
cd boost-root
|
||||
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
|
||||
git submodule update --init tools/boostdep
|
||||
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
cd ../boost-root
|
||||
mkdir __build__ && cd __build__
|
||||
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
|
||||
|
||||
- name: Build tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
cmake --build . --target tests
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
cd ../boost-root/__build__
|
||||
ctest --output-on-failure --no-tests=error
|
307
.travis.yml
307
.travis.yml
@ -22,28 +22,48 @@ matrix:
|
||||
- env: BOGUS_JOB=true
|
||||
|
||||
include:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14,17
|
||||
|
||||
- os: linux
|
||||
dist: focal
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14,17
|
||||
|
||||
- os: linux
|
||||
arch: arm64
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14
|
||||
|
||||
- os: linux
|
||||
arch: ppc64le
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14
|
||||
|
||||
- os: linux
|
||||
arch: s390x
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
|
||||
env: TOOLSET=gcc CXXSTD=03,11,14
|
||||
|
||||
- os: freebsd
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,17,2a
|
||||
env: TOOLSET=clang CXXSTD=03,11,14,17,2a
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
env: TOOLSET=gcc CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -53,7 +73,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
env: TOOLSET=gcc CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -61,109 +81,10 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-9
|
||||
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14
|
||||
env: UBSAN=1 TOOLSET=gcc CXXSTD=03,11,14 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -174,7 +95,7 @@ matrix:
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: g++-10
|
||||
env: TOOLSET=gcc COMPILER=g++-10 CXXSTD=17,2a
|
||||
env: UBSAN=1 TOOLSET=gcc CXXSTD=17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -182,20 +103,10 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
env: TOOLSET=clang COMMENT=clang-3.3 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@ -204,160 +115,24 @@ matrix:
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
env: TOOLSET=clang COMMENT=clang-3.4 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11
|
||||
compiler: clang++-11
|
||||
env: UBSAN=1 TOOLSET=clang CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- clang-11
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang++-9
|
||||
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main'
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
dist: xenial
|
||||
compiler: clang++-10
|
||||
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-10
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- sourceline: 'deb https://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main'
|
||||
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-8
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-xenial-8
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: clang++-libc++
|
||||
@ -367,9 +142,14 @@ matrix:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
- os: linux
|
||||
dist: bionic
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
@ -380,6 +160,7 @@ matrix:
|
||||
script:
|
||||
- mkdir __build__ && cd __build__
|
||||
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=smart_ptr -DBUILD_TESTING=ON ..
|
||||
- cmake --build . --target tests -- -k
|
||||
- ctest --output-on-failure -R boost_smart_ptr
|
||||
|
||||
- os: linux
|
||||
@ -434,7 +215,7 @@ install:
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
echo "using $TOOLSET : : $TRAVIS_COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
|
13
appveyor.yml
13
appveyor.yml
@ -16,6 +16,7 @@ environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
|
||||
ADDRMD: 32
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-12.0,msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
@ -23,14 +24,10 @@ environment:
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
TOOLSET: clang-win
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
@ -82,4 +79,4 @@ test_script:
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release embed-manifest-via=linker
|
||||
|
@ -14,6 +14,8 @@ Greg Colvin, Beman Dawes, Peter Dimov, Glen Fernandes
|
||||
:idprefix:
|
||||
:listing-caption: Code Example
|
||||
:docinfo: private-footer
|
||||
:source-highlighter: rouge
|
||||
:source-language: c++
|
||||
|
||||
:leveloffset: +1
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
////
|
||||
Copyright 2019 Glen Joseph Fernandes (glenjofe@gmail.com)
|
||||
Copyright 2019-2021 Glen Joseph Fernandes (glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
@ -85,6 +85,11 @@ namespace boost {
|
||||
template<class T, class A>
|
||||
std::unique_ptr<remove_extent_t<T>[], alloc_noinit_deleter<T, A>>
|
||||
allocate_unique_noinit(const A& a);
|
||||
|
||||
template<class T, class U, class A>
|
||||
allocator_pointer_t<allocator_rebind_t<A, remove_cv_t<remove_extent_t<T>>>>
|
||||
get_allocator_pointer(const std::unique_ptr<T,
|
||||
alloc_deleter<U, A>>& p) noexcept;
|
||||
}
|
||||
```
|
||||
|
||||
@ -269,6 +274,18 @@ Returns:: A `std::unique_ptr` to a sequence of `extent_v<T>`
|
||||
default-initialized objects of type `remove_extent_t<T>`.
|
||||
Example:: `auto p = allocate_unique_noinit<double[1024]>(a);`
|
||||
|
||||
```
|
||||
template<class T, class U, class A>
|
||||
allocator_pointer_t<allocator_rebind_t<A, remove_cv_t<remove_extent_t<T>>>>
|
||||
get_allocator_pointer(const std::unique_ptr<T,
|
||||
alloc_deleter<U, A>>& p) noexcept;
|
||||
```
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Returns:: The allocator pointer to the allocation.
|
||||
Example:: `auto r = boost::get_allocator_ptr(p);`
|
||||
|
||||
## Deleter
|
||||
|
||||
Class template `alloc_deleter` is the deleter used by the `allocate_unique`
|
||||
|
@ -13,6 +13,10 @@ http://www.boost.org/LICENSE_1_0.txt
|
||||
:toc-title:
|
||||
:idprefix: changelog_
|
||||
|
||||
## Changes in 1.79.0
|
||||
|
||||
* Added `get_allocator_pointer`
|
||||
|
||||
## Changes in 1.74.0
|
||||
|
||||
* Added `owner_equals` to `shared_ptr`, `weak_ptr`, `local_shared_ptr`
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Glen Joseph Fernandes
|
||||
Copyright 2019-2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@ -477,6 +477,15 @@ allocate_unique(const A& alloc,
|
||||
return c.release();
|
||||
}
|
||||
|
||||
template<class T, class U, class A>
|
||||
inline typename allocator_pointer<typename allocator_rebind<A,
|
||||
typename detail::sp_alloc_value<T>::type>::type>::type
|
||||
get_allocator_pointer(const std::unique_ptr<T,
|
||||
alloc_deleter<U, A> >& p) BOOST_NOEXCEPT
|
||||
{
|
||||
return p.get().ptr();
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@ -387,7 +387,7 @@ public:
|
||||
{
|
||||
typedef typename sp_convert_reference<D>::type D2;
|
||||
|
||||
D2 d2( r.get_deleter() );
|
||||
D2 d2( static_cast<D&&>( r.get_deleter() ) );
|
||||
pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
|
||||
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
|
@ -35,8 +35,6 @@ BOOST_PRAGMA_MESSAGE("Using CodeWarrior/PowerPC sp_counted_base")
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_SP_OBSOLETE()
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
@ -64,7 +62,11 @@ inline long atomic_decrement( register long * pw )
|
||||
|
||||
asm
|
||||
{
|
||||
#if defined(__PPCZen__) || defined(__PPCe500__) || defined(__PPCe500v2__)
|
||||
msync
|
||||
#else
|
||||
sync
|
||||
#endif
|
||||
|
||||
loop:
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
@ -145,7 +145,7 @@ template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public
|
||||
private:
|
||||
|
||||
P ptr; // copy constructor must not throw
|
||||
D del; // copy constructor must not throw
|
||||
D del; // copy/move constructor must not throw
|
||||
|
||||
sp_counted_impl_pd( sp_counted_impl_pd const & );
|
||||
sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );
|
||||
@ -156,10 +156,20 @@ public:
|
||||
|
||||
// pre: d(p) must not throw
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
sp_counted_impl_pd( P p, D & d ): ptr( p ), del( static_cast< D&& >( d ) )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
sp_counted_impl_pd( P p, D & d ): ptr( p ), del( d )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sp_counted_impl_pd( P p ): ptr( p ), del()
|
||||
{
|
||||
}
|
||||
@ -218,7 +228,7 @@ template<class P, class D, class A> class BOOST_SYMBOL_VISIBLE sp_counted_impl_p
|
||||
private:
|
||||
|
||||
P p_; // copy constructor must not throw
|
||||
D d_; // copy constructor must not throw
|
||||
D d_; // copy/move constructor must not throw
|
||||
A a_; // copy constructor must not throw
|
||||
|
||||
sp_counted_impl_pda( sp_counted_impl_pda const & );
|
||||
@ -230,10 +240,20 @@ public:
|
||||
|
||||
// pre: d( p ) must not throw
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( static_cast< D&& >( d ) ), a_( a )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
sp_counted_impl_pda( P p, D & d, A a ): p_( p ), d_( d ), a_( a )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
sp_counted_impl_pda( P p, A a ): p_( p ), d_( a ), a_( a )
|
||||
{
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <memory> // TR1 cyclic inclusion fix
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#include <boost/smart_ptr/detail/shared_count.hpp>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <boost/smart_ptr/detail/sp_nullptr_t.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/core/checked_delete.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
@ -374,39 +374,81 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
// Requirements: D's copy constructor must not throw
|
||||
// Requirements: D's copy/move constructors must not throw
|
||||
//
|
||||
// shared_ptr will release p by calling d(p)
|
||||
//
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, static_cast< D&& >( d ) )
|
||||
{
|
||||
boost::detail::sp_deleter_construct( this, p );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Y, class D> shared_ptr( Y * p, D d ): px( p ), pn( p, d )
|
||||
{
|
||||
boost::detail::sp_deleter_construct( this, p );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, static_cast< D&& >( d ) )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// As above, but with allocator. A's copy constructor shall not throw.
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, static_cast< D&& >( d ), a )
|
||||
{
|
||||
boost::detail::sp_deleter_construct( this, p );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Y, class D, class A> shared_ptr( Y * p, D d, A a ): px( p ), pn( p, d, a )
|
||||
{
|
||||
boost::detail::sp_deleter_construct( this, p );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, static_cast< D&& >( d ), a )
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a )
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// generated copy constructor, destructor are fine...
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
@ -625,9 +667,8 @@ public:
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
shared_ptr( shared_ptr && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn()
|
||||
shared_ptr( shared_ptr && r ) BOOST_SP_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::shared_count && >( r.pn ) )
|
||||
{
|
||||
pn.swap( r.pn );
|
||||
r.px = 0;
|
||||
}
|
||||
|
||||
@ -641,11 +682,9 @@ public:
|
||||
shared_ptr( shared_ptr<Y> && r )
|
||||
|
||||
#endif
|
||||
BOOST_SP_NOEXCEPT : px( r.px ), pn()
|
||||
BOOST_SP_NOEXCEPT : px( r.px ), pn( static_cast< boost::detail::shared_count && >( r.pn ) )
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
|
||||
pn.swap( r.pn );
|
||||
r.px = 0;
|
||||
}
|
||||
|
||||
@ -693,6 +732,20 @@ public:
|
||||
this_type( p ).swap( *this );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
template<class Y, class D> void reset( Y * p, D d )
|
||||
{
|
||||
this_type( p, static_cast< D&& >( d ) ).swap( *this );
|
||||
}
|
||||
|
||||
template<class Y, class D, class A> void reset( Y * p, D d, A a )
|
||||
{
|
||||
this_type( p, static_cast< D&& >( d ), a ).swap( *this );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
template<class Y, class D> void reset( Y * p, D d )
|
||||
{
|
||||
this_type( p, d ).swap( *this );
|
||||
@ -703,6 +756,8 @@ public:
|
||||
this_type( p, d, a ).swap( *this );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template<class Y> void reset( shared_ptr<Y> const & r, element_type * p ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
this_type( r, p ).swap( *this );
|
||||
|
@ -16,6 +16,7 @@
|
||||
"Memory"
|
||||
],
|
||||
"maintainers": [
|
||||
"Peter Dimov <pdimov -at- pdimov.com>"
|
||||
]
|
||||
"Peter Dimov <pdimov -at- gmail.com>"
|
||||
],
|
||||
"cxxstd": "03"
|
||||
}
|
||||
|
12
test/Jamfile
12
test/Jamfile
@ -81,7 +81,7 @@ run sp_recursive_assign_rv_test.cpp ;
|
||||
run sp_recursive_assign2_rv_test.cpp ;
|
||||
|
||||
compile-fail auto_ptr_lv_fail.cpp
|
||||
: <toolset>gcc-4.4.7:<build>no ;
|
||||
: <toolset>gcc-4.4.7:<build>no <toolset>gcc-4.4:<build>no ;
|
||||
|
||||
run atomic_count_test2.cpp ;
|
||||
run sp_typeinfo_test.cpp ;
|
||||
@ -331,9 +331,9 @@ run weak_ptr_alias_move_test.cpp ;
|
||||
|
||||
run sp_typeinfo_test.cpp : : : <rtti>off : sp_typeinfo_test_no_rtti ;
|
||||
|
||||
run get_deleter_test.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no : get_deleter_test_no_rtti ;
|
||||
run get_deleter_test2.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no : get_deleter_test2_no_rtti ;
|
||||
run get_deleter_test3.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no : get_deleter_test3_no_rtti ;
|
||||
run get_deleter_test.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test_no_rtti ;
|
||||
run get_deleter_test2.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test2_no_rtti ;
|
||||
run get_deleter_test3.cpp : : : <rtti>off <toolset>gcc-4.4.7,<cxxstd>0x:<build>no <toolset>gcc-4.4,<cxxstd>0x:<build>no : get_deleter_test3_no_rtti ;
|
||||
|
||||
run shared_from_test.cpp ;
|
||||
run weak_from_test.cpp ;
|
||||
@ -352,6 +352,7 @@ run allocate_unique_noinit_test.cpp ;
|
||||
run allocate_unique_test.cpp ;
|
||||
run allocate_unique_throws_test.cpp ;
|
||||
run allocate_unique_value_test.cpp ;
|
||||
run get_allocator_pointer_test.cpp ;
|
||||
|
||||
run sp_guides_test.cpp ;
|
||||
run sp_guides_test2.cpp ;
|
||||
@ -408,3 +409,6 @@ run wp_unordered_test.cpp ;
|
||||
|
||||
run owner_hash_test.cpp ;
|
||||
run sp_unordered_test.cpp ;
|
||||
|
||||
run sp_unique_ptr_test2.cpp ;
|
||||
run sp_move_only_deleter.cpp ;
|
||||
|
250
test/get_allocator_pointer_test.cpp
Normal file
250
test/get_allocator_pointer_test.cpp
Normal file
@ -0,0 +1,250 @@
|
||||
/*
|
||||
Copyright 2021 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if (!defined(BOOST_LIBSTDCXX_VERSION) || \
|
||||
BOOST_LIBSTDCXX_VERSION >= 46000) && \
|
||||
!defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
#include <boost/smart_ptr/allocate_unique.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
template<class T>
|
||||
class point {
|
||||
public:
|
||||
point()
|
||||
: state_()
|
||||
, ptr_() { }
|
||||
|
||||
point(int count, T* value)
|
||||
: state_(count)
|
||||
, ptr_(value) { }
|
||||
|
||||
operator bool() const {
|
||||
return static_cast<bool>(ptr_);
|
||||
}
|
||||
|
||||
T* operator->() const {
|
||||
return ptr_;
|
||||
}
|
||||
|
||||
int state() const {
|
||||
return state_;
|
||||
}
|
||||
|
||||
private:
|
||||
int state_;
|
||||
T* ptr_;
|
||||
};
|
||||
|
||||
template<class T = void>
|
||||
class creator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef point<T> pointer;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
|
||||
creator()
|
||||
: state_() { }
|
||||
|
||||
explicit creator(int value)
|
||||
: state_(value) { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>& other)
|
||||
: state_(other.state()) { }
|
||||
|
||||
pointer allocate(std::size_t size) {
|
||||
return pointer(state_,
|
||||
static_cast<T*>(::operator new(sizeof(T) * size)));
|
||||
}
|
||||
|
||||
void deallocate(pointer ptr, std::size_t) {
|
||||
::operator delete(ptr.operator->());
|
||||
}
|
||||
|
||||
int state() const {
|
||||
return state_;
|
||||
}
|
||||
|
||||
private:
|
||||
int state_;
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::unique_ptr<int,
|
||||
boost::alloc_deleter<int, creator<> > > result =
|
||||
boost::allocate_unique<int>(creator<>(1));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 1);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int,
|
||||
boost::alloc_deleter<const int, creator<> > > result =
|
||||
boost::allocate_unique<const int>(creator<>(2));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 2);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[],
|
||||
boost::alloc_deleter<int[], creator<> > > result =
|
||||
boost::allocate_unique<int[]>(creator<>(3), 3);
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 3);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[],
|
||||
boost::alloc_deleter<int[3], creator<> > > result =
|
||||
boost::allocate_unique<int[3]>(creator<>(4));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 4);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[][2],
|
||||
boost::alloc_deleter<int[][2], creator<> > > result =
|
||||
boost::allocate_unique<int[][2]>(creator<>(5), 2);
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 5);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[][2],
|
||||
boost::alloc_deleter<int[2][2], creator<> > > result =
|
||||
boost::allocate_unique<int[2][2]>(creator<>(6));
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 6);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[],
|
||||
boost::alloc_deleter<const int[], creator<> > > result =
|
||||
boost::allocate_unique<const int[]>(creator<>(7), 3);
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 7);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[],
|
||||
boost::alloc_deleter<const int[3], creator<> > > result =
|
||||
boost::allocate_unique<const int[3]>(creator<>(8));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 8);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[][2],
|
||||
boost::alloc_deleter<const int[][2], creator<> > > result =
|
||||
boost::allocate_unique<const int[][2]>(creator<>(9), 2);
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 9);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[][2],
|
||||
boost::alloc_deleter<const int[2][2], creator<> > > result =
|
||||
boost::allocate_unique<const int[2][2]>(creator<>(10));
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 10);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int,
|
||||
boost::alloc_deleter<int,
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<int>(creator<>(11));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 11);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int,
|
||||
boost::alloc_deleter<const int,
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<const int>(creator<>(12));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 12);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[],
|
||||
boost::alloc_deleter<int[],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<int[]>(creator<>(13), 3);
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 13);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[],
|
||||
boost::alloc_deleter<int[3],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<int[3]>(creator<>(14));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 14);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[][2],
|
||||
boost::alloc_deleter<int[][2],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<int[][2]>(creator<>(15), 2);
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 15);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<int[][2],
|
||||
boost::alloc_deleter<int[2][2],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<int[2][2]>(creator<>(16));
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 16);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[],
|
||||
boost::alloc_deleter<const int[],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<const int[]>(creator<>(17), 3);
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 17);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[],
|
||||
boost::alloc_deleter<const int[3],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<const int[3]>(creator<>(18));
|
||||
point<int> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 18);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[][2],
|
||||
boost::alloc_deleter<const int[][2],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<const int[][2]>(creator<>(19), 2);
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 19);
|
||||
}
|
||||
{
|
||||
std::unique_ptr<const int[][2],
|
||||
boost::alloc_deleter<const int[2][2],
|
||||
boost::noinit_adaptor<creator<> > > > result =
|
||||
boost::allocate_unique_noinit<const int[2][2]>(creator<>(20));
|
||||
point<int[2]> ptr = boost::get_allocator_pointer(result);
|
||||
BOOST_TEST_EQ(ptr.state(), 20);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
153
test/sp_move_only_deleter.cpp
Normal file
153
test/sp_move_only_deleter.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
// Copyright 2021 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 <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_RVALUE_REFERENCES is defined")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
struct Y
|
||||
{
|
||||
static int instances;
|
||||
|
||||
bool deleted_;
|
||||
|
||||
Y(): deleted_( false )
|
||||
{
|
||||
++instances;
|
||||
}
|
||||
|
||||
~Y()
|
||||
{
|
||||
BOOST_TEST( deleted_ );
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Y( Y const & );
|
||||
Y & operator=( Y const & );
|
||||
};
|
||||
|
||||
int Y::instances = 0;
|
||||
|
||||
struct YD
|
||||
{
|
||||
bool moved_;
|
||||
|
||||
YD(): moved_( false )
|
||||
{
|
||||
}
|
||||
|
||||
YD( YD&& r ): moved_( false )
|
||||
{
|
||||
r.moved_ = true;
|
||||
}
|
||||
|
||||
void operator()( Y* p ) const
|
||||
{
|
||||
BOOST_TEST( !moved_ );
|
||||
|
||||
if( p )
|
||||
{
|
||||
p->deleted_ = true;
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
YD( YD const & );
|
||||
YD & operator=( YD const & );
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
|
||||
{
|
||||
YD del;
|
||||
boost::shared_ptr<Y> p( new Y, std::move( del ) );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( del.moved_ );
|
||||
|
||||
p.reset( new Y, YD() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
p = boost::shared_ptr<Y>( new Y, YD() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
YD del2;
|
||||
p.reset( new Y, std::move( del2 ) );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( del2.moved_ );
|
||||
|
||||
p.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
YD del;
|
||||
boost::shared_ptr<Y> p( new Y, std::move( del ), std::allocator<Y>() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( del.moved_ );
|
||||
|
||||
p.reset( new Y, YD(), std::allocator<Y>() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
p = boost::shared_ptr<Y>( new Y, YD(), std::allocator<Y>() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
YD del2;
|
||||
p.reset( new Y, std::move( del2 ), std::allocator<Y>() );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( del2.moved_ );
|
||||
|
||||
p.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||
|
||||
{
|
||||
boost::shared_ptr<Y> p( nullptr, YD() );
|
||||
|
||||
YD del;
|
||||
p = boost::shared_ptr<Y>( nullptr, std::move( del ) );
|
||||
|
||||
BOOST_TEST( del.moved_ );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<Y> p( nullptr, YD(), std::allocator<Y>() );
|
||||
|
||||
YD del;
|
||||
p = boost::shared_ptr<Y>( nullptr, std::move( del ), std::allocator<Y>() );
|
||||
|
||||
BOOST_TEST( del.moved_ );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
153
test/sp_unique_ptr_test2.cpp
Normal file
153
test/sp_unique_ptr_test2.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
// Copyright 2021 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 <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#if defined( BOOST_NO_CXX11_SMART_PTR )
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_SMART_PTR is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX11_RVALUE_REFERENCES is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_MSVC) && BOOST_MSVC < 1700
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because msvc-10.0 unique_ptr doesn't support move-only deleters")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
struct Y
|
||||
{
|
||||
static int instances;
|
||||
|
||||
bool deleted_;
|
||||
|
||||
Y(): deleted_( false )
|
||||
{
|
||||
++instances;
|
||||
}
|
||||
|
||||
~Y()
|
||||
{
|
||||
BOOST_TEST( deleted_ );
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Y( Y const & );
|
||||
Y & operator=( Y const & );
|
||||
};
|
||||
|
||||
int Y::instances = 0;
|
||||
|
||||
struct YD
|
||||
{
|
||||
bool moved_;
|
||||
|
||||
YD(): moved_( false )
|
||||
{
|
||||
}
|
||||
|
||||
YD( YD&& r ): moved_( false )
|
||||
{
|
||||
r.moved_ = true;
|
||||
}
|
||||
|
||||
void operator()( Y* p ) const
|
||||
{
|
||||
BOOST_TEST( !moved_ );
|
||||
|
||||
if( p )
|
||||
{
|
||||
p->deleted_ = true;
|
||||
delete p;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_ERROR( "YD::operator()(0) called" );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
YD( YD const & );
|
||||
YD & operator=( YD const & );
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
|
||||
{
|
||||
std::unique_ptr<Y, YD> p( new Y );
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
boost::shared_ptr<Y> p2( std::move( p ) );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
BOOST_TEST( p.get_deleter().moved_ );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<Y, YD> p( new Y );
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
boost::shared_ptr<void> p2( std::move( p ) );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
BOOST_TEST( p.get_deleter().moved_ );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<Y, YD> p( new Y );
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
boost::shared_ptr<Y> p2;
|
||||
p2 = std::move( p );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
BOOST_TEST( p.get_deleter().moved_ );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_ptr<Y, YD> p( new Y );
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
|
||||
boost::shared_ptr<void> p2( new int(0) );
|
||||
p2 = std::move( p );
|
||||
|
||||
BOOST_TEST( Y::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
BOOST_TEST( p.get_deleter().moved_ );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( Y::instances == 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user