mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-10-04 19:51:02 +02:00
Compare commits
38 Commits
feature/re
...
develop
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
@@ -179,22 +179,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,22 +333,22 @@ 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",
|
||||
"Linux 24.04 Clang 17 UBSAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + ubsan,
|
||||
"clang-17",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 23.10 Clang 17 ASAN",
|
||||
"cppalliance/droneubuntu2310:1",
|
||||
"Linux 24.04 Clang 17 ASAN",
|
||||
"cppalliance/droneubuntu2404:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-17', CXXSTD: '11,14,17,20,2b' } + asan,
|
||||
"clang-17",
|
||||
),
|
||||
@@ -367,6 +367,13 @@ local windows_pipeline(name, image, environment, arch = "amd64") =
|
||||
"clang-18",
|
||||
),
|
||||
|
||||
linux_pipeline(
|
||||
"Linux 24.10 Clang 19",
|
||||
"cppalliance/droneubuntu2410:1",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++-19', CXXSTD: '11,14,17,20,2b' },
|
||||
"clang-19",
|
||||
),
|
||||
|
||||
macos_pipeline(
|
||||
"MacOS 10.15 Xcode 12.2 UBSAN",
|
||||
{ TOOLSET: 'clang', COMPILER: 'clang++', CXXSTD: '11,14,1z' } + ubsan,
|
||||
|
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
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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 ) );
|
||||
|
||||
|
@@ -21,21 +21,20 @@
|
||||
#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 <boost/smart_ptr/detail/sp_type_traits.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <new> // ::operator new, ::operator delete
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<unsigned size, unsigned align_> union freeblock
|
||||
{
|
||||
typedef typename boost::type_with_alignment<align_>::type aligner_type;
|
||||
typedef typename sp_type_with_alignment<align_>::type aligner_type;
|
||||
aligner_type aligner;
|
||||
char bytes[size];
|
||||
freeblock * next;
|
||||
@@ -74,7 +73,7 @@ template<unsigned size, unsigned align_> struct allocator_impl
|
||||
|
||||
static lightweight_mutex & mutex()
|
||||
{
|
||||
static freeblock< sizeof( lightweight_mutex ), boost::alignment_of< lightweight_mutex >::value > fbm;
|
||||
static freeblock< sizeof( lightweight_mutex ), std::alignment_of< lightweight_mutex >::value > fbm;
|
||||
static lightweight_mutex * pm = new( &fbm ) lightweight_mutex;
|
||||
return *pm;
|
||||
}
|
||||
@@ -188,7 +187,7 @@ 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 >
|
||||
struct quick_allocator: public allocator_impl< sizeof(T), std::alignment_of<T>::value >
|
||||
{
|
||||
};
|
||||
|
||||
|
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 */
|
||||
|
@@ -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;
|
||||
|
55
test/Jamfile
55
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,12 @@ 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 ;
|
||||
|
@@ -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);
|
||||
|
@@ -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