forked from boostorg/smart_ptr
Compare commits
12 Commits
boost-1.78
...
develop
Author | SHA1 | Date | |
---|---|---|---|
|
59b5b17e81 | ||
|
f2ab3b21f0 | ||
|
e04196b6a1 | ||
|
95eaa2d7c3 | ||
|
2e31d0d633 | ||
|
b8cb132ab4 | ||
|
f4d7116241 | ||
|
f2cc84a23c | ||
|
f12a33813d | ||
|
cfde4f7407 | ||
|
b8d340b495 | ||
|
6716193d9c |
219
.github/workflows/ci.yml
vendored
219
.github/workflows/ci.yml
vendored
@@ -20,33 +20,48 @@ jobs:
|
|||||||
- toolset: gcc-4.8
|
- toolset: gcc-4.8
|
||||||
cxxstd: "03,11"
|
cxxstd: "03,11"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
install: g++-4.8
|
install: g++-4.8-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-5
|
- toolset: gcc-5
|
||||||
cxxstd: "03,11,14,1z"
|
cxxstd: "03,11,14,1z"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
install: g++-5
|
install: g++-5-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-6
|
- toolset: gcc-6
|
||||||
cxxstd: "03,11,14,1z"
|
cxxstd: "03,11,14,1z"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
install: g++-6
|
install: g++-6-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-7
|
- toolset: gcc-7
|
||||||
cxxstd: "03,11,14,17"
|
cxxstd: "03,11,14,17"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
|
install: g++-7-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-8
|
- toolset: gcc-8
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-18.04
|
os: ubuntu-18.04
|
||||||
install: g++-8
|
install: g++-8-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-9
|
- toolset: gcc-9
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
|
install: g++-9-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-10
|
- toolset: gcc-10
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: g++-10
|
install: g++-10-multilib
|
||||||
|
address-model: 32,64
|
||||||
- toolset: gcc-11
|
- toolset: gcc-11
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,20"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: g++-11
|
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
|
- toolset: clang
|
||||||
compiler: clang++-3.9
|
compiler: clang++-3.9
|
||||||
cxxstd: "03,11,14"
|
cxxstd: "03,11,14"
|
||||||
@@ -86,17 +101,24 @@ jobs:
|
|||||||
compiler: clang++-10
|
compiler: clang++-10
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: clang-10
|
|
||||||
- toolset: clang
|
- toolset: clang
|
||||||
compiler: clang++-11
|
compiler: clang++-11
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: clang-11
|
|
||||||
- toolset: clang
|
- toolset: clang
|
||||||
compiler: clang++-12
|
compiler: clang++-12
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,20"
|
||||||
os: ubuntu-20.04
|
os: ubuntu-20.04
|
||||||
install: clang-12
|
- 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
|
- toolset: clang
|
||||||
cxxstd: "03,11,14,17,2a"
|
cxxstd: "03,11,14,17,2a"
|
||||||
os: macos-10.15
|
os: macos-10.15
|
||||||
@@ -140,22 +162,26 @@ jobs:
|
|||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
cd ../boost-root
|
cd ../boost-root
|
||||||
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} variant=debug,release
|
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- toolset: msvc-14.1
|
- toolset: msvc-14.0
|
||||||
cxxstd: "14,17,latest"
|
cxxstd: 14,latest
|
||||||
addrmd: 32,64
|
addrmd: 32,64
|
||||||
os: windows-2016
|
os: windows-2019
|
||||||
- toolset: msvc-14.2
|
- toolset: msvc-14.2
|
||||||
cxxstd: "14,17,latest"
|
cxxstd: "14,17,20,latest"
|
||||||
addrmd: 32,64
|
addrmd: 32,64
|
||||||
os: windows-2019
|
os: windows-2019
|
||||||
- toolset: msvc-14.3
|
- toolset: msvc-14.3
|
||||||
|
cxxstd: "14,17,20,latest"
|
||||||
|
addrmd: 32,64
|
||||||
|
os: windows-2022
|
||||||
|
- toolset: clang-win
|
||||||
cxxstd: "14,17,latest"
|
cxxstd: "14,17,latest"
|
||||||
addrmd: 32,64
|
addrmd: 32,64
|
||||||
os: windows-2022
|
os: windows-2022
|
||||||
@@ -195,4 +221,163 @@ jobs:
|
|||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
cd ../boost-root
|
cd ../boost-root
|
||||||
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
|
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
|
||||||
|
10
appveyor.yml
10
appveyor.yml
@@ -24,14 +24,10 @@ environment:
|
|||||||
TOOLSET: msvc-14.1
|
TOOLSET: msvc-14.1
|
||||||
CXXSTD: 14,17
|
CXXSTD: 14,17
|
||||||
ADDRMD: 32,64
|
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
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||||
TOOLSET: msvc-14.2
|
TOOLSET: clang-win
|
||||||
CXXSTD: 14,17,latest
|
CXXSTD: 14,17,latest
|
||||||
ADDRMD: 32,64
|
ADDRMD: 64
|
||||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||||
ADDPATH: C:\cygwin\bin;
|
ADDPATH: C:\cygwin\bin;
|
||||||
TOOLSET: gcc
|
TOOLSET: gcc
|
||||||
@@ -83,4 +79,4 @@ test_script:
|
|||||||
- PATH=%ADDPATH%%PATH%
|
- PATH=%ADDPATH%%PATH%
|
||||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
- 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
|
||||||
|
@@ -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.
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
|
|
||||||
@@ -85,6 +85,11 @@ namespace boost {
|
|||||||
template<class T, class A>
|
template<class T, class A>
|
||||||
std::unique_ptr<remove_extent_t<T>[], alloc_noinit_deleter<T, A>>
|
std::unique_ptr<remove_extent_t<T>[], alloc_noinit_deleter<T, A>>
|
||||||
allocate_unique_noinit(const A& 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>`.
|
default-initialized objects of type `remove_extent_t<T>`.
|
||||||
Example:: `auto p = allocate_unique_noinit<double[1024]>(a);`
|
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
|
## Deleter
|
||||||
|
|
||||||
Class template `alloc_deleter` is the deleter used by the `allocate_unique`
|
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:
|
:toc-title:
|
||||||
:idprefix: changelog_
|
:idprefix: changelog_
|
||||||
|
|
||||||
|
## Changes in 1.79.0
|
||||||
|
|
||||||
|
* Added `get_allocator_pointer`
|
||||||
|
|
||||||
## Changes in 1.74.0
|
## Changes in 1.74.0
|
||||||
|
|
||||||
* Added `owner_equals` to `shared_ptr`, `weak_ptr`, `local_shared_ptr`
|
* 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)
|
(glenjofe@gmail.com)
|
||||||
|
|
||||||
Distributed under the Boost Software License, Version 1.0.
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
@@ -477,6 +477,15 @@ allocate_unique(const A& alloc,
|
|||||||
return c.release();
|
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 */
|
} /* boost */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
|
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_noexcept.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/throw_exception.hpp>
|
||||||
#include <boost/core/addressof.hpp>
|
#include <boost/core/addressof.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
@@ -35,8 +35,6 @@ BOOST_PRAGMA_MESSAGE("Using CodeWarrior/PowerPC sp_counted_base")
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_SP_OBSOLETE()
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -64,7 +62,11 @@ inline long atomic_decrement( register long * pw )
|
|||||||
|
|
||||||
asm
|
asm
|
||||||
{
|
{
|
||||||
|
#if defined(__PPCZen__) || defined(__PPCe500__) || defined(__PPCe500v2__)
|
||||||
|
msync
|
||||||
|
#else
|
||||||
sync
|
sync
|
||||||
|
#endif
|
||||||
|
|
||||||
loop:
|
loop:
|
||||||
|
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
|
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_noexcept.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/core/addressof.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/assert.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_nullptr_t.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/assert.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_nullptr_t.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#include <memory> // TR1 cyclic inclusion fix
|
#include <memory> // TR1 cyclic inclusion fix
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#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/shared_ptr.hpp>
|
||||||
#include <boost/smart_ptr/detail/shared_count.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_nullptr_t.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||||
#include <boost/smart_ptr/detail/sp_noexcept.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/throw_exception.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
@@ -667,9 +667,8 @@ public:
|
|||||||
|
|
||||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
#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;
|
r.px = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,11 +682,9 @@ public:
|
|||||||
shared_ptr( shared_ptr<Y> && r )
|
shared_ptr( shared_ptr<Y> && r )
|
||||||
|
|
||||||
#endif
|
#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 >();
|
boost::detail::sp_assert_convertible< Y, T >();
|
||||||
|
|
||||||
pn.swap( r.pn );
|
|
||||||
r.px = 0;
|
r.px = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -352,6 +352,7 @@ run allocate_unique_noinit_test.cpp ;
|
|||||||
run allocate_unique_test.cpp ;
|
run allocate_unique_test.cpp ;
|
||||||
run allocate_unique_throws_test.cpp ;
|
run allocate_unique_throws_test.cpp ;
|
||||||
run allocate_unique_value_test.cpp ;
|
run allocate_unique_value_test.cpp ;
|
||||||
|
run get_allocator_pointer_test.cpp ;
|
||||||
|
|
||||||
run sp_guides_test.cpp ;
|
run sp_guides_test.cpp ;
|
||||||
run sp_guides_test2.cpp ;
|
run sp_guides_test2.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
|
Reference in New Issue
Block a user