mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-10-05 04:01:04 +02:00
Compare commits
120 Commits
feature/lo
...
boost-1.70
Author | SHA1 | Date | |
---|---|---|---|
|
4fbb9ff076 | ||
|
8ccb36dfcf | ||
|
fde2e91443 | ||
|
aa1341a6a2 | ||
|
053779f3ee | ||
|
51d8167fbf | ||
|
5f95fe9848 | ||
|
599d0bbba9 | ||
|
f769217ca8 | ||
|
5d5d28a92e | ||
|
85fd341402 | ||
|
eac6411867 | ||
|
97ef7970e8 | ||
|
4baa21dd5e | ||
|
d0a89a81f0 | ||
|
ab2b977e4a | ||
|
f380d4466c | ||
|
2932ca4203 | ||
|
660d26c2c3 | ||
|
a095084492 | ||
|
a314765b94 | ||
|
02eba55685 | ||
|
9c2c991291 | ||
|
2e57ddb953 | ||
|
f6c3508aee | ||
|
b7cca00408 | ||
|
7e50abb9ec | ||
|
e7360779b0 | ||
|
456da93897 | ||
|
04f0847af4 | ||
|
29a08cdff6 | ||
|
6d3af760f6 | ||
|
a9f39d2b94 | ||
|
4e2f236116 | ||
|
4eb53db537 | ||
|
a2b6ba85f3 | ||
|
e37cd4154f | ||
|
8563fc5c4e | ||
|
67fab5c9ec | ||
|
f16fbdce26 | ||
|
c3b3835a58 | ||
|
d1600b8abc | ||
|
5885763287 | ||
|
9bb12692b3 | ||
|
773ef80f5d | ||
|
704de2bd67 | ||
|
1caa233faa | ||
|
605d4a2789 | ||
|
6ab9b93088 | ||
|
4129bb6a5c | ||
|
3b64e5ecb3 | ||
|
4025698fe8 | ||
|
2d7ab197a7 | ||
|
5877b08490 | ||
|
ffe5b46f75 | ||
|
4abc74fe28 | ||
|
12a646c607 | ||
|
937a3e0e93 | ||
|
258fa75a7e | ||
|
93d0d69f5e | ||
|
f173f9c0fb | ||
|
6a5942f55f | ||
|
293a4ee009 | ||
|
8e3aa3a565 | ||
|
78bebd5166 | ||
|
a47cf35b0f | ||
|
8d0afb670f | ||
|
77a35856c6 | ||
|
693109361e | ||
|
6735806863 | ||
|
b0dc300154 | ||
|
adc998469a | ||
|
4252ed31de | ||
|
279372a784 | ||
|
b77b7cfd62 | ||
|
2553a71b79 | ||
|
5dfcd2a6e4 | ||
|
6f30b395e4 | ||
|
014318a1ba | ||
|
d2c8eea08d | ||
|
4e0d47302b | ||
|
765840cd71 | ||
|
cb4a878fa8 | ||
|
57a585ed46 | ||
|
949338ff18 | ||
|
50fbbe91d8 | ||
|
e88227b506 | ||
|
410f2ce8d4 | ||
|
4e2e758f58 | ||
|
9cb8ee086f | ||
|
a054a570c1 | ||
|
219dc523ec | ||
|
5da882293d | ||
|
868a870a59 | ||
|
10c6233029 | ||
|
bcfe1be681 | ||
|
966786e7f9 | ||
|
087471a232 | ||
|
06bd43d5b5 | ||
|
1758d44e4c | ||
|
1c13ec0888 | ||
|
cc7eb56f51 | ||
|
eb64ae8daa | ||
|
a3c8c2125a | ||
|
3aa419463c | ||
|
e4ba116d7e | ||
|
864a0c80dd | ||
|
be736e5088 | ||
|
48294c483f | ||
|
13e73d6a78 | ||
|
20a517cc3d | ||
|
65d412c840 | ||
|
d031d4719f | ||
|
c1979bcaf5 | ||
|
0adb1fb212 | ||
|
7410cb1733 | ||
|
2d087d0003 | ||
|
ca7a01a593 | ||
|
314a6634d4 | ||
|
6cbc1e6775 |
425
.travis.yml
425
.travis.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2016-2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -6,10 +6,6 @@ language: cpp
|
||||
|
||||
sudo: false
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
@@ -28,21 +24,31 @@ matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=c++03
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++03
|
||||
compiler: g++-4.4
|
||||
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.7
|
||||
- g++-4.4
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.6
|
||||
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.7
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=c++11
|
||||
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -52,37 +58,16 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++03
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.8
|
||||
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-4.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.9
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=c++11
|
||||
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -92,37 +77,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-5
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=c++1z
|
||||
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -132,7 +87,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++03
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -141,39 +96,8 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-6
|
||||
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=c++1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++03
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -182,31 +106,18 @@ matrix:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++11
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
dist: trusty
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=c++17
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -216,92 +127,39 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.3
|
||||
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.4
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.5
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=c++1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.5
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.5
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.6
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.6
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.6
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=c++1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -312,40 +170,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.7
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=c++1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -356,95 +181,31 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.8
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=c++1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.8
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.8
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++03
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++11
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++14
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-3.9
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=c++1z
|
||||
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-3.9
|
||||
- libstdc++-4.9-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-precise-3.9
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++03
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -454,53 +215,78 @@ matrix:
|
||||
- llvm-toolchain-trusty-4.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++11
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- clang-5.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++14
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-4.0
|
||||
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=c++1z
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-4.0
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-4.0
|
||||
- llvm-toolchain-trusty-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
- libstdc++-5-dev
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-7
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-libc++
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libc++-dev
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++03
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++11
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++14
|
||||
|
||||
- os: osx
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=c++1z
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: CMAKE_SUBDIR_TEST=1
|
||||
script:
|
||||
- cd libs/smart_ptr/test/cmake_subdir_test && mkdir __build__ && cd __build__
|
||||
- cmake ..
|
||||
- cmake --build .
|
||||
- cmake --build . --target check
|
||||
|
||||
install:
|
||||
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
|
||||
@@ -511,26 +297,27 @@ install:
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/atomic
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/functional
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/move
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/integer
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- git submodule init libs/headers
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 3
|
||||
- cp -r $TRAVIS_BUILD_DIR/* libs/smart_ptr
|
||||
- ./bootstrap.sh
|
||||
- ./b2 headers
|
||||
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
|
||||
- ./b2 libs/smart_ptr/test toolset=$TOOLSET
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
26
CMakeLists.txt
Normal file
26
CMakeLists.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2018 Mike Dev
|
||||
# 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
|
||||
|
||||
# Partial (add_subdirectory only) and experimental CMake support
|
||||
# Subject to change; please do not rely on the contents of this file yet
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(BoostSmartPtr LANGUAGES CXX)
|
||||
|
||||
add_library(boost_smart_ptr INTERFACE)
|
||||
add_library(Boost::smart_ptr ALIAS boost_smart_ptr)
|
||||
|
||||
target_include_directories(boost_smart_ptr INTERFACE include)
|
||||
|
||||
target_link_libraries(boost_smart_ptr
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::core
|
||||
Boost::move
|
||||
Boost::predef
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
Boost::type_traits
|
||||
)
|
@@ -2,5 +2,5 @@
|
||||
|
||||
Branch | Travis | Appveyor
|
||||
---------|--------|---------
|
||||
Develop | [](https://travis-ci.org/boostorg/smart_ptr) | [](https://ci.appveyor.com/project/pdimov/smart_ptr)
|
||||
Master | [](https://travis-ci.org/boostorg/smart_ptr) | [](https://ci.appveyor.com/project/pdimov/smart_ptr)
|
||||
Develop | [](https://travis-ci.org/boostorg/smart_ptr) | [](https://ci.appveyor.com/project/pdimov/smart-ptr)
|
||||
Master | [](https://travis-ci.org/boostorg/smart_ptr) | [](https://ci.appveyor.com/project/pdimov/smart-ptr)
|
||||
|
53
appveyor.yml
53
appveyor.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017 Peter Dimov
|
||||
# Copyright 2016-2018 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
|
||||
@@ -15,45 +15,62 @@ branches:
|
||||
environment:
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-9.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-10.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-11.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
TOOLSET: msvc-12.0
|
||||
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
|
||||
TOOLSET: msvc-14.0
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\cygwin64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
|
||||
ADDPATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;
|
||||
TOOLSET: gcc
|
||||
CXXSTD: 03,11,14,1z
|
||||
|
||||
install:
|
||||
- set BOOST_BRANCH=develop
|
||||
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
|
||||
- cd ..
|
||||
- git clone -b %BOOST_BRANCH% https://github.com/boostorg/boost.git boost-root
|
||||
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
|
||||
- cd boost-root
|
||||
- git submodule init libs/align
|
||||
- git submodule init libs/assert
|
||||
- git submodule init libs/atomic
|
||||
- git submodule init libs/config
|
||||
- git submodule init libs/container_hash
|
||||
- git submodule init libs/core
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/functional
|
||||
- git submodule init libs/integer
|
||||
- git submodule init libs/move
|
||||
- git submodule init libs/predef
|
||||
- git submodule init libs/preprocessor
|
||||
- git submodule init libs/static_assert
|
||||
- git submodule init libs/throw_exception
|
||||
- git submodule init libs/type_traits
|
||||
- git submodule init libs/detail
|
||||
- git submodule init libs/integer
|
||||
- git submodule init tools/build
|
||||
- git submodule update
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\smart_ptr
|
||||
- bootstrap
|
||||
- b2 headers
|
||||
- git submodule init libs/headers
|
||||
- git submodule init tools/boost_install
|
||||
- git submodule update --jobs 3
|
||||
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\smart_ptr\
|
||||
- cmd /c bootstrap
|
||||
- b2 -d0 headers
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- b2 libs/smart_ptr/test toolset=%TOOLSET%
|
||||
- PATH=%ADDPATH%%PATH%
|
||||
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
|
||||
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
|
||||
- b2 -j3 libs/smart_ptr/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release
|
||||
|
@@ -1,50 +0,0 @@
|
||||
# Copyright 2017 Peter Dimov
|
||||
#
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import type ;
|
||||
import scanner ;
|
||||
import generators ;
|
||||
import boostbook ;
|
||||
|
||||
# File type
|
||||
|
||||
type.register ASCIIDOC : asciidoc adoc ;
|
||||
|
||||
# Define dependency scanner
|
||||
|
||||
class asciidoc-scanner : common-scanner
|
||||
{
|
||||
rule pattern ( )
|
||||
{
|
||||
return "include::([^[]+)\\[" ;
|
||||
}
|
||||
}
|
||||
|
||||
scanner.register asciidoc-scanner : include ;
|
||||
type.set-scanner ASCIIDOC : asciidoc-scanner ;
|
||||
|
||||
# Define generators
|
||||
|
||||
generators.register-standard asciidoctor.asciidoc-to-html : ASCIIDOC : HTML ;
|
||||
generators.register-standard asciidoctor.asciidoc-to-pdf : ASCIIDOC : PDF ;
|
||||
# generators.register-standard asciidoctor.asciidoc-to-docbook : ASCIIDOC : DOCBOOK ;
|
||||
|
||||
# Define actions
|
||||
|
||||
actions asciidoc-to-html
|
||||
{
|
||||
asciidoctor -b html -o $(1) $(2)
|
||||
}
|
||||
|
||||
actions asciidoc-to-pdf
|
||||
{
|
||||
asciidoctor -r asciidoctor-pdf -b pdf -o $(1) $(2)
|
||||
}
|
||||
|
||||
actions asciidoc-to-docbook
|
||||
{
|
||||
asciidoctor -b docbook -o $(1) $(2)
|
||||
}
|
@@ -39,6 +39,8 @@ include::smart_ptr/intrusive_ref_counter.adoc[]
|
||||
|
||||
include::smart_ptr/local_shared_ptr.adoc[]
|
||||
|
||||
include::smart_ptr/make_local_shared.adoc[]
|
||||
|
||||
include::smart_ptr/pointer_cast.adoc[]
|
||||
|
||||
include::smart_ptr/pointer_to_other.adoc[]
|
||||
|
@@ -110,4 +110,4 @@ Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more
|
||||
|
||||
Peter Dimov and Glen Fernandes rewrote the documentation in Asciidoc format.
|
||||
|
||||
Peter Dimov added `atomic_shared_ptr`.
|
||||
Peter Dimov added `atomic_shared_ptr` and `local_shared_ptr`.
|
||||
|
@@ -54,12 +54,18 @@ namespace boost {
|
||||
intrusive_ptr(intrusive_ptr const & r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
|
||||
|
||||
intrusive_ptr(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
|
||||
|
||||
~intrusive_ptr();
|
||||
|
||||
intrusive_ptr & operator=(intrusive_ptr const & r);
|
||||
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> const & r);
|
||||
intrusive_ptr & operator=(T * r);
|
||||
|
||||
intrusive_ptr & operator=(intrusive_ptr && r);
|
||||
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
|
||||
|
||||
void reset();
|
||||
void reset(T * r);
|
||||
void reset(T * r, bool add_ref);
|
||||
@@ -92,8 +98,8 @@ namespace boost {
|
||||
template<class T, class U>
|
||||
bool operator!=(T * a, intrusive_ptr<U> const & b) noexcept;
|
||||
|
||||
template<class T, class U>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
|
||||
template<class T>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
|
||||
|
||||
template<class T> void swap(intrusive_ptr<T> & a, intrusive_ptr<T> & b) noexcept;
|
||||
|
||||
@@ -155,9 +161,21 @@ template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: `if(r.get() != 0) intrusive_ptr_add_ref(r.get());`.
|
||||
Effects:: `T * p = r.get(); if(p != 0) intrusive_ptr_add_ref(p);`.
|
||||
Postconditions:: `get() == r.get()`.
|
||||
|
||||
```
|
||||
intrusive_ptr(intrusive_ptr && r);
|
||||
```
|
||||
```
|
||||
template<class Y> intrusive_ptr(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Postconditions:: `get()` equals the old value of `r.get()`. `r.get() == 0`.
|
||||
|
||||
### destructor
|
||||
|
||||
```
|
||||
@@ -187,6 +205,19 @@ intrusive_ptr & operator=(T * r);
|
||||
Effects:: Equivalent to `intrusive_ptr(r).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
```
|
||||
intrusive_ptr & operator=(intrusive_ptr && r);
|
||||
```
|
||||
```
|
||||
template<class Y> intrusive_ptr & operator=(intrusive_ptr<Y> && r);
|
||||
```
|
||||
|
||||
[none]
|
||||
* {blank}
|
||||
+
|
||||
Effects:: Equivalent to `intrusive_ptr(std::move(r)).swap(*this)`.
|
||||
Returns:: `*this`.
|
||||
|
||||
### reset
|
||||
|
||||
```
|
||||
@@ -361,8 +392,8 @@ template<class T, class U>
|
||||
Returns:: `a != b.get()`.
|
||||
|
||||
```
|
||||
template<class T, class U>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<U> const & b) noexcept;
|
||||
template<class T>
|
||||
bool operator<(intrusive_ptr<T> const & a, intrusive_ptr<T> const & b) noexcept;
|
||||
```
|
||||
|
||||
[none]
|
||||
|
81
doc/smart_ptr/make_local_shared.adoc
Normal file
81
doc/smart_ptr/make_local_shared.adoc
Normal file
@@ -0,0 +1,81 @@
|
||||
////
|
||||
Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
|
||||
|
||||
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
|
||||
////
|
||||
|
||||
[#make_local_shared]
|
||||
# make_local_shared: Creating local_shared_ptr
|
||||
:toc:
|
||||
:toc-title:
|
||||
:idprefix: make_local_shared_
|
||||
|
||||
## Description
|
||||
|
||||
The function templates `make_local_shared` and `allocate_local_shared` provide
|
||||
convenient, safe and efficient ways to create `local_shared_ptr` objects. They
|
||||
are analogous to `make_shared` and `allocate_shared` for `shared_ptr`.
|
||||
|
||||
## Synopsis
|
||||
|
||||
`make_local_shared` and `allocate_local_shared` are defined in
|
||||
`<boost/smart_ptr/make_local_shared.hpp>`.
|
||||
|
||||
[subs=+quotes]
|
||||
```
|
||||
namespace boost {
|
||||
`// only if T is not an array type`
|
||||
template<class T, class... Args>
|
||||
local_shared_ptr<T> make_local_shared(Args&&... args);
|
||||
template<class T, class A, class... Args>
|
||||
local_shared_ptr<T> allocate_local_shared(const A& a, Args&&... args);
|
||||
|
||||
`// only if T is an array type of the form U[]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared(std::size_t n);
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n);
|
||||
|
||||
`// only if T is an array type of the form U[N]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared();
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared(const A& a);
|
||||
|
||||
`// only if T is an array type of the form U[]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared(std::size_t n,
|
||||
const remove_extent_t<T>& v);
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n,
|
||||
const remove_extent_t<T>& v);
|
||||
|
||||
`// only if T is an array type of the form U[N]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared(const remove_extent_t<T>& v);
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared(const A& a,
|
||||
const remove_extent_t<T>& v);
|
||||
|
||||
`// only if T is not an array type of the form U[]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared_noinit();
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared_noinit(const A& a);
|
||||
|
||||
`// only if T is an array type of the form U[N]`
|
||||
template<class T>
|
||||
local_shared_ptr<T> make_local_shared_noinit(std::size_t n);
|
||||
template<class T, class A>
|
||||
local_shared_ptr<T> allocate_local_shared_noinit(const A& a,
|
||||
std::size_t n);
|
||||
}
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The requirements and effects of these functions are the same as `make_shared`
|
||||
and `allocate_shared`, except that a `local_shared_ptr` is returned.
|
@@ -35,7 +35,7 @@ feature with `std::make_unique`.
|
||||
|
||||
## Synopsis
|
||||
|
||||
`make_unique` is defined in `<boost/smart_ptr/make_unqiue.hpp>`.
|
||||
`make_unique` is defined in `<boost/smart_ptr/make_unique.hpp>`.
|
||||
|
||||
[subs=+quotes]
|
||||
```
|
||||
|
@@ -251,7 +251,7 @@ Note, however, that `shared_ptr` copies created from `pw` will not "register" in
|
||||
they will share the single reference created in `make_shared_from_COM`. Weak pointers created from `pw` will be invalidated when the last
|
||||
`shared_ptr` is destroyed, regardless of whether the COM object itself is still alive.
|
||||
|
||||
As link:../../libs/bind/mem_fn.html#Q3[explained] in the `mem_fn` documentation, you need to `#define BOOST_MEM_FN_ENABLE_STDCALL` first.
|
||||
As link:../../../../libs/bind/mem_fn.html#Q3[explained] in the `mem_fn` documentation, you need to `#define BOOST_MEM_FN_ENABLE_STDCALL` first.
|
||||
|
||||
[#techniques_intrusive]
|
||||
## Using a shared_ptr to hold a pointer to an object with an embedded reference count
|
||||
|
@@ -62,7 +62,7 @@ int main()
|
||||
|
||||
clock_t t = clock();
|
||||
|
||||
pthread_t a[ m ];
|
||||
boost::detail::lw_thread_t a[ m ];
|
||||
|
||||
for( int i = 0; i < m; ++i )
|
||||
{
|
||||
@@ -71,7 +71,7 @@ int main()
|
||||
|
||||
for( int j = 0; j < m; ++j )
|
||||
{
|
||||
pthread_join( a[j], 0 );
|
||||
boost::detail::lw_thread_join( a[j] );
|
||||
}
|
||||
|
||||
t = clock() - t;
|
||||
|
@@ -228,7 +228,7 @@ int main( int ac, char const * av[] )
|
||||
|
||||
clock_t t = clock();
|
||||
|
||||
std::vector<pthread_t> a( m );
|
||||
std::vector<boost::detail::lw_thread_t> a( m );
|
||||
|
||||
for( int i = 0; i < m; ++i )
|
||||
{
|
||||
@@ -237,7 +237,7 @@ int main( int ac, char const * av[] )
|
||||
|
||||
for( int j = 0; j < m; ++j )
|
||||
{
|
||||
pthread_join( a[ j ], 0 );
|
||||
boost::detail::lw_thread_join( a[ j ] );
|
||||
}
|
||||
|
||||
t = clock() - t;
|
||||
|
@@ -165,7 +165,7 @@ int main()
|
||||
|
||||
clock_t t = clock();
|
||||
|
||||
pthread_t a[ mr+mw ];
|
||||
boost::detail::lw_thread_t a[ mr+mw ];
|
||||
|
||||
for( int i = 0; i < mr; ++i )
|
||||
{
|
||||
@@ -179,7 +179,7 @@ int main()
|
||||
|
||||
for( int j = 0; j < mr+mw; ++j )
|
||||
{
|
||||
pthread_join( a[ j ], 0 );
|
||||
boost::detail::lw_thread_join( a[ j ] );
|
||||
}
|
||||
|
||||
t = clock() - t;
|
||||
|
@@ -100,7 +100,7 @@ int main()
|
||||
|
||||
clock_t t = clock();
|
||||
|
||||
pthread_t a[ m ];
|
||||
boost::detail::lw_thread_t a[ m ];
|
||||
|
||||
for( int i = 0; i < m; ++i )
|
||||
{
|
||||
@@ -111,7 +111,7 @@ int main()
|
||||
|
||||
for( int j = 0; j < m; ++j )
|
||||
{
|
||||
pthread_join( a[j], 0 );
|
||||
boost::detail::lw_thread_join( a[j] );
|
||||
}
|
||||
|
||||
t = clock() - t;
|
||||
|
@@ -10,30 +10,59 @@
|
||||
// boost/detail/lightweight_thread.hpp
|
||||
//
|
||||
// Copyright (c) 2002 Peter Dimov and Multi Media Ltd.
|
||||
// Copyright (c) 2008 Peter Dimov
|
||||
// Copyright (c) 2008, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
//
|
||||
// typedef /*...*/ lw_thread_t; // as pthread_t
|
||||
// template<class F> int lw_thread_create( lw_thread_t & th, F f );
|
||||
// void lw_thread_join( lw_thread_t th );
|
||||
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <memory>
|
||||
#include <cerrno>
|
||||
|
||||
// pthread_create, pthread_join
|
||||
|
||||
#if defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#else
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
typedef ::pthread_t lw_thread_t;
|
||||
|
||||
inline int lw_thread_create_( lw_thread_t* thread, const pthread_attr_t* attr, void* (*start_routine)( void* ), void* arg )
|
||||
{
|
||||
return ::pthread_create( thread, attr, start_routine, arg );
|
||||
}
|
||||
|
||||
inline void lw_thread_join( lw_thread_t th )
|
||||
{
|
||||
::pthread_join( th, 0 );
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#else // defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
typedef HANDLE pthread_t;
|
||||
namespace boost
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
|
||||
typedef HANDLE lw_thread_t;
|
||||
|
||||
inline int lw_thread_create_( lw_thread_t * thread, void const *, unsigned (__stdcall * start_routine) (void*), void* arg )
|
||||
{
|
||||
HANDLE h = (HANDLE)_beginthreadex( 0, 0, start_routine, arg, 0, 0 );
|
||||
|
||||
@@ -48,20 +77,20 @@ int pthread_create( pthread_t * thread, void const *, unsigned (__stdcall * star
|
||||
}
|
||||
}
|
||||
|
||||
int pthread_join( pthread_t thread, void ** /*value_ptr*/ )
|
||||
inline void lw_thread_join( lw_thread_t thread )
|
||||
{
|
||||
::WaitForSingleObject( thread, INFINITE );
|
||||
::CloseHandle( thread );
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
#endif // defined( BOOST_HAS_PTHREADS )
|
||||
|
||||
// template<class F> int lw_thread_create( pthread_t & pt, F f );
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@@ -77,8 +106,16 @@ public:
|
||||
|
||||
extern "C" void * lw_thread_routine( void * pv )
|
||||
{
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
#else
|
||||
|
||||
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
#endif
|
||||
|
||||
pt->run();
|
||||
|
||||
return 0;
|
||||
@@ -88,8 +125,16 @@ extern "C" void * lw_thread_routine( void * pv )
|
||||
|
||||
unsigned __stdcall lw_thread_routine( void * pv )
|
||||
{
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
std::auto_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
#else
|
||||
|
||||
std::unique_ptr<lw_abstract_thread> pt( static_cast<lw_abstract_thread *>( pv ) );
|
||||
|
||||
#endif
|
||||
|
||||
pt->run();
|
||||
|
||||
return 0;
|
||||
@@ -115,11 +160,19 @@ private:
|
||||
F f_;
|
||||
};
|
||||
|
||||
template<class F> int lw_thread_create( pthread_t & pt, F f )
|
||||
template<class F> int lw_thread_create( lw_thread_t & th, F f )
|
||||
{
|
||||
#if defined(BOOST_NO_CXX11_SMART_PTR)
|
||||
|
||||
std::auto_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
|
||||
|
||||
int r = pthread_create( &pt, 0, lw_thread_routine, p.get() );
|
||||
#else
|
||||
|
||||
std::unique_ptr<lw_abstract_thread> p( new lw_thread_impl<F>( f ) );
|
||||
|
||||
#endif
|
||||
|
||||
int r = lw_thread_create_( &th, 0, lw_thread_routine, p.get() );
|
||||
|
||||
if( r == 0 )
|
||||
{
|
||||
|
220
include/boost/smart_ptr/allocate_local_shared_array.hpp
Normal file
220
include/boost/smart_ptr/allocate_local_shared_array.hpp
Normal file
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
Copyright 2017-2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
|
||||
#define BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
|
||||
|
||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
class BOOST_SYMBOL_VISIBLE lsp_array_base
|
||||
: public local_counted_base {
|
||||
public:
|
||||
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
|
||||
count_ = shared_count(base);
|
||||
}
|
||||
|
||||
virtual void local_cb_destroy() BOOST_SP_NOEXCEPT {
|
||||
shared_count().swap(count_);
|
||||
}
|
||||
|
||||
virtual shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT {
|
||||
return count_;
|
||||
}
|
||||
|
||||
private:
|
||||
shared_count count_;
|
||||
};
|
||||
|
||||
template<class A>
|
||||
class lsp_array_state
|
||||
: public sp_array_state<A> {
|
||||
public:
|
||||
template<class U>
|
||||
lsp_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
|
||||
: sp_array_state<A>(other, size) { }
|
||||
|
||||
lsp_array_base& base() BOOST_SP_NOEXCEPT {
|
||||
return base_;
|
||||
}
|
||||
|
||||
private:
|
||||
lsp_array_base base_;
|
||||
};
|
||||
|
||||
template<class A, std::size_t N>
|
||||
class lsp_size_array_state
|
||||
: public sp_size_array_state<A, N> {
|
||||
public:
|
||||
template<class U>
|
||||
lsp_size_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
|
||||
: sp_size_array_state<A, N>(other, size) { }
|
||||
|
||||
lsp_array_base& base() BOOST_SP_NOEXCEPT {
|
||||
return base_;
|
||||
}
|
||||
|
||||
private:
|
||||
lsp_array_base base_;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator, std::size_t count)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
typedef detail::lsp_array_state<other> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
std::size_t size = count * detail::sp_array_count<type, scalar>::value;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(allocator, size, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
enum {
|
||||
size = detail::sp_array_count<T, scalar>::value
|
||||
};
|
||||
typedef detail::lsp_size_array_state<other, size> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(allocator, size, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator, std::size_t count,
|
||||
const typename remove_extent<T>::type& value)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
typedef detail::lsp_array_state<other> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
enum {
|
||||
total = detail::sp_array_count<type, scalar>::value
|
||||
};
|
||||
std::size_t size = count * total;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(allocator, size,
|
||||
reinterpret_cast<const scalar*>(&value), total, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared(const A& allocator,
|
||||
const typename remove_extent<T>::type& value)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
enum {
|
||||
size = detail::sp_array_count<T, scalar>::value
|
||||
};
|
||||
typedef detail::lsp_size_array_state<other, size> state;
|
||||
typedef detail::sp_array_base<state> base;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(allocator, size,
|
||||
reinterpret_cast<const scalar*>(&value),
|
||||
detail::sp_array_count<type, scalar>::value, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared_noinit(const A& allocator, std::size_t count)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
typedef detail::lsp_array_state<other> state;
|
||||
typedef detail::sp_array_base<state, false> base;
|
||||
std::size_t size = count * detail::sp_array_count<type, scalar>::value;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(detail::sp_default(), allocator,
|
||||
size, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
template<class T, class A>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
allocate_local_shared_noinit(const A& allocator)
|
||||
{
|
||||
typedef typename remove_extent<T>::type type;
|
||||
typedef typename detail::sp_array_scalar<T>::type scalar;
|
||||
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
|
||||
enum {
|
||||
size = detail::sp_array_count<T, scalar>::value
|
||||
};
|
||||
typedef detail::lsp_size_array_state<other, size> state;
|
||||
typedef detail::sp_array_base<state, false> base;
|
||||
detail::sp_array_result<other, base> result(allocator, size);
|
||||
base* node = result.get();
|
||||
scalar* start = detail::sp_array_start<base, scalar>(node);
|
||||
::new(static_cast<void*>(node)) base(detail::sp_default(), allocator,
|
||||
size, start);
|
||||
detail::lsp_array_base& local = node->state().base();
|
||||
local.set(node);
|
||||
result.release();
|
||||
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
|
||||
reinterpret_cast<type*>(start), &local);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@@ -97,7 +97,13 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
shared_ptr<T> load( int = 0 ) const BOOST_SP_NOEXCEPT
|
||||
shared_ptr<T> load() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
return p_;
|
||||
}
|
||||
|
||||
template<class M> shared_ptr<T> load( M ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
return p_;
|
||||
@@ -109,13 +115,19 @@ public:
|
||||
return p_;
|
||||
}
|
||||
|
||||
void store( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
void store( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
shared_ptr<T> exchange( shared_ptr<T> r, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> void store( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
shared_ptr<T> exchange( shared_ptr<T> r ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
@@ -133,44 +145,82 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
template<class M> shared_ptr<T> exchange( shared_ptr<T> r, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
{
|
||||
boost::detail::spinlock::scoped_lock lock( l_ );
|
||||
p_.swap( r );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
return std::move( r );
|
||||
|
||||
#else
|
||||
|
||||
return r;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, const shared_ptr<T>& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, w );
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int, int ) BOOST_SP_NOEXCEPT
|
||||
bool compare_exchange_weak( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, int = 0 ) BOOST_SP_NOEXCEPT
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
template<class M> bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w, M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
||||
bool compare_exchange_strong( shared_ptr<T>& v, shared_ptr<T>&& w ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return compare_exchange( v, std::move( w ) );
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class bad_weak_ptr: public std::exception
|
||||
{
|
||||
public:
|
||||
|
||||
virtual char const * what() const throw()
|
||||
virtual char const * what() const BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{
|
||||
return "tr1::bad_weak_ptr";
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
#include <boost/smart_ptr/detail/shared_count.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <utility>
|
||||
#include <climits>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -28,7 +27,7 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class local_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE local_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -37,7 +36,7 @@ private:
|
||||
private:
|
||||
|
||||
// not 'int' or 'unsigned' to avoid aliasing and enable optimizations
|
||||
enum count_type { min_ = 0, initial_ = 1, max_ = UINT_MAX };
|
||||
enum count_type { min_ = 0, initial_ = 1, max_ = 2147483647 };
|
||||
|
||||
count_type local_use_count_;
|
||||
|
||||
@@ -61,11 +60,13 @@ public:
|
||||
|
||||
void add_ref() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
#if !defined(__NVCC__)
|
||||
#if defined( __has_builtin )
|
||||
# if __has_builtin( __builtin_assume )
|
||||
|
||||
__builtin_assume( local_use_count_ >= 1 );
|
||||
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -88,7 +89,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class local_counted_impl: public local_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE local_counted_impl: public local_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -100,13 +101,13 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
explicit local_counted_impl( shared_count const& pn ): pn_( pn )
|
||||
explicit local_counted_impl( shared_count const& pn ) BOOST_SP_NOEXCEPT: pn_( pn )
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
explicit local_counted_impl( shared_count && pn ): pn_( std::move(pn) )
|
||||
explicit local_counted_impl( shared_count && pn ) BOOST_SP_NOEXCEPT: pn_( std::move(pn) )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class local_counted_impl_em: public local_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE local_counted_impl_em: public local_counted_base
|
||||
{
|
||||
public:
|
||||
|
||||
|
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
D& deleter()
|
||||
D& deleter() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return d_;
|
||||
}
|
||||
@@ -74,12 +74,12 @@ template<> class local_sp_deleter<void>
|
||||
{
|
||||
};
|
||||
|
||||
template<class D> D * get_local_deleter( local_sp_deleter<D> * p )
|
||||
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return &p->deleter();
|
||||
}
|
||||
|
||||
inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ )
|
||||
inline void * get_local_deleter( local_sp_deleter<void> * /*p*/ ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -61,10 +61,23 @@ extern "C" __declspec(dllimport) void __stdcall EnterCriticalSection(::_RTL_CRIT
|
||||
extern "C" __declspec(dllimport) void __stdcall LeaveCriticalSection(::_RTL_CRITICAL_SECTION *);
|
||||
extern "C" __declspec(dllimport) void __stdcall DeleteCriticalSection(::_RTL_CRITICAL_SECTION *);
|
||||
|
||||
#else
|
||||
typedef ::_RTL_CRITICAL_SECTION rtl_critical_section;
|
||||
|
||||
#else // #ifndef BOOST_USE_WINDOWS_H
|
||||
|
||||
typedef ::CRITICAL_SECTION critical_section;
|
||||
|
||||
#if BOOST_PLAT_WINDOWS_RUNTIME
|
||||
using ::InitializeCriticalSectionEx;
|
||||
#else
|
||||
using ::InitializeCriticalSection;
|
||||
#endif
|
||||
using ::EnterCriticalSection;
|
||||
using ::LeaveCriticalSection;
|
||||
using ::DeleteCriticalSection;
|
||||
|
||||
typedef ::CRITICAL_SECTION rtl_critical_section;
|
||||
|
||||
#endif // #ifndef BOOST_USE_WINDOWS_H
|
||||
|
||||
class lightweight_mutex
|
||||
@@ -81,15 +94,15 @@ public:
|
||||
lightweight_mutex()
|
||||
{
|
||||
#if BOOST_PLAT_WINDOWS_RUNTIME
|
||||
boost::detail::InitializeCriticalSectionEx(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_), 4000, 0);
|
||||
boost::detail::InitializeCriticalSectionEx(reinterpret_cast< rtl_critical_section* >(&cs_), 4000, 0);
|
||||
#else
|
||||
boost::detail::InitializeCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_));
|
||||
boost::detail::InitializeCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
|
||||
#endif
|
||||
}
|
||||
|
||||
~lightweight_mutex()
|
||||
{
|
||||
boost::detail::DeleteCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&cs_));
|
||||
boost::detail::DeleteCriticalSection(reinterpret_cast< rtl_critical_section* >(&cs_));
|
||||
}
|
||||
|
||||
class scoped_lock;
|
||||
@@ -108,12 +121,12 @@ public:
|
||||
|
||||
explicit scoped_lock(lightweight_mutex & m): m_(m)
|
||||
{
|
||||
boost::detail::EnterCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_));
|
||||
boost::detail::EnterCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
|
||||
}
|
||||
|
||||
~scoped_lock()
|
||||
{
|
||||
boost::detail::LeaveCriticalSection(reinterpret_cast< ::_RTL_CRITICAL_SECTION* >(&m_.cs_));
|
||||
boost::detail::LeaveCriticalSection(reinterpret_cast< rtl_critical_section* >(&m_.cs_));
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@@ -29,7 +29,8 @@
|
||||
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_counted_impl.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_disable_deprecated.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/config/workaround.hpp>
|
||||
// In order to avoid circular dependencies with Boost.TR1
|
||||
// we make sure that our include of <memory> doesn't try to
|
||||
// pull in the TR1 headers: that's why we use this header
|
||||
@@ -118,7 +119,14 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
BOOST_CONSTEXPR shared_count(): pi_(0) // nothrow
|
||||
BOOST_CONSTEXPR shared_count() BOOST_SP_NOEXCEPT: pi_(0)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_CONSTEXPR explicit shared_count( sp_counted_base * pi ) BOOST_SP_NOEXCEPT: pi_( pi )
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
@@ -414,7 +422,7 @@ public:
|
||||
r.release();
|
||||
}
|
||||
|
||||
~shared_count() // nothrow
|
||||
~shared_count() /*BOOST_SP_NOEXCEPT*/
|
||||
{
|
||||
if( pi_ != 0 ) pi_->release();
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
@@ -422,7 +430,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
shared_count(shared_count const & r): pi_(r.pi_) // nothrow
|
||||
shared_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
@@ -432,7 +440,7 @@ public:
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
shared_count(shared_count && r): pi_(r.pi_) // nothrow
|
||||
shared_count(shared_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
@@ -443,9 +451,9 @@ public:
|
||||
#endif
|
||||
|
||||
explicit shared_count(weak_count const & r); // throws bad_weak_ptr when r.use_count() == 0
|
||||
shared_count( weak_count const & r, sp_nothrow_tag ); // constructs an empty *this when r.use_count() == 0
|
||||
shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT; // constructs an empty *this when r.use_count() == 0
|
||||
|
||||
shared_count & operator= (shared_count const & r) // nothrow
|
||||
shared_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
|
||||
@@ -459,49 +467,49 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(shared_count & r) // nothrow
|
||||
void swap(shared_count & r) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
r.pi_ = pi_;
|
||||
pi_ = tmp;
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
long use_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_ != 0? pi_->use_count(): 0;
|
||||
}
|
||||
|
||||
bool unique() const // nothrow
|
||||
bool unique() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return use_count() == 1;
|
||||
}
|
||||
|
||||
bool empty() const // nothrow
|
||||
bool empty() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_ == 0;
|
||||
}
|
||||
|
||||
friend inline bool operator==(shared_count const & a, shared_count const & b)
|
||||
friend inline bool operator==(shared_count const & a, shared_count const & b) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
friend inline bool operator<(shared_count const & a, shared_count const & b)
|
||||
friend inline bool operator<(shared_count const & a, shared_count const & b) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return std::less<sp_counted_base *>()( a.pi_, b.pi_ );
|
||||
}
|
||||
|
||||
void * get_deleter( sp_typeinfo const & ti ) const
|
||||
void * get_deleter( sp_typeinfo const & ti ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_? pi_->get_deleter( ti ): 0;
|
||||
}
|
||||
|
||||
void * get_local_deleter( sp_typeinfo const & ti ) const
|
||||
void * get_local_deleter( sp_typeinfo const & ti ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_? pi_->get_local_deleter( ti ): 0;
|
||||
}
|
||||
|
||||
void * get_untyped_deleter() const
|
||||
void * get_untyped_deleter() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_? pi_->get_untyped_deleter(): 0;
|
||||
}
|
||||
@@ -522,14 +530,14 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
BOOST_CONSTEXPR weak_count(): pi_(0) // nothrow
|
||||
BOOST_CONSTEXPR weak_count() BOOST_SP_NOEXCEPT: pi_(0)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
weak_count(shared_count const & r): pi_(r.pi_) // nothrow
|
||||
weak_count(shared_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
@@ -537,7 +545,7 @@ public:
|
||||
if(pi_ != 0) pi_->weak_add_ref();
|
||||
}
|
||||
|
||||
weak_count(weak_count const & r): pi_(r.pi_) // nothrow
|
||||
weak_count(weak_count const & r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
@@ -549,7 +557,7 @@ public:
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
weak_count(weak_count && r): pi_(r.pi_) // nothrow
|
||||
weak_count(weak_count && r) BOOST_SP_NOEXCEPT: pi_(r.pi_)
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(weak_count_id)
|
||||
#endif
|
||||
@@ -559,7 +567,7 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
~weak_count() // nothrow
|
||||
~weak_count() /*BOOST_SP_NOEXCEPT*/
|
||||
{
|
||||
if(pi_ != 0) pi_->weak_release();
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
@@ -567,7 +575,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
weak_count & operator= (shared_count const & r) // nothrow
|
||||
weak_count & operator= (shared_count const & r) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
|
||||
@@ -581,7 +589,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
weak_count & operator= (weak_count const & r) // nothrow
|
||||
weak_count & operator= (weak_count const & r) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
|
||||
@@ -595,29 +603,29 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(weak_count & r) // nothrow
|
||||
void swap(weak_count & r) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
sp_counted_base * tmp = r.pi_;
|
||||
r.pi_ = pi_;
|
||||
pi_ = tmp;
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
long use_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_ != 0? pi_->use_count(): 0;
|
||||
}
|
||||
|
||||
bool empty() const // nothrow
|
||||
bool empty() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pi_ == 0;
|
||||
}
|
||||
|
||||
friend inline bool operator==(weak_count const & a, weak_count const & b)
|
||||
friend inline bool operator==(weak_count const & a, weak_count const & b) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.pi_ == b.pi_;
|
||||
}
|
||||
|
||||
friend inline bool operator<(weak_count const & a, weak_count const & b)
|
||||
friend inline bool operator<(weak_count const & a, weak_count const & b) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return std::less<sp_counted_base *>()(a.pi_, b.pi_);
|
||||
}
|
||||
@@ -634,7 +642,7 @@ inline shared_count::shared_count( weak_count const & r ): pi_( r.pi_ )
|
||||
}
|
||||
}
|
||||
|
||||
inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ): pi_( r.pi_ )
|
||||
inline shared_count::shared_count( weak_count const & r, sp_nothrow_tag ) BOOST_SP_NOEXCEPT: pi_( r.pi_ )
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
, id_(shared_count_id)
|
||||
#endif
|
||||
|
@@ -16,6 +16,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <machine/sys/inline.h>
|
||||
|
||||
namespace boost
|
||||
@@ -71,7 +72,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <builtins.h>
|
||||
#include <sys/atomic_op.h>
|
||||
|
||||
@@ -63,7 +64,7 @@ inline int32_t atomic_conditional_increment( int32_t * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -16,6 +16,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -26,17 +28,17 @@ namespace detail
|
||||
|
||||
typedef _Atomic( boost::int_least32_t ) atomic_int_least32_t;
|
||||
|
||||
inline void atomic_increment( atomic_int_least32_t * pw )
|
||||
inline void atomic_increment( atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
__c11_atomic_fetch_add( pw, 1, __ATOMIC_RELAXED );
|
||||
}
|
||||
|
||||
inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw )
|
||||
inline boost::int_least32_t atomic_decrement( atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return __c11_atomic_fetch_sub( pw, 1, __ATOMIC_ACQ_REL );
|
||||
}
|
||||
|
||||
inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw )
|
||||
inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
// long r = *pw;
|
||||
// if( r != 0 ) ++*pw;
|
||||
@@ -63,7 +65,7 @@ inline boost::int_least32_t atomic_conditional_increment( atomic_int_least32_t *
|
||||
# pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#endif
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -75,43 +77,43 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
sp_counted_base()
|
||||
sp_counted_base() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
__c11_atomic_init( &use_count_, 1 );
|
||||
__c11_atomic_init( &weak_count_, 1 );
|
||||
}
|
||||
|
||||
virtual ~sp_counted_base() // nothrow
|
||||
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
|
||||
{
|
||||
}
|
||||
|
||||
// dispose() is called when use_count_ drops to zero, to release
|
||||
// the resources managed by *this.
|
||||
|
||||
virtual void dispose() = 0; // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT = 0; // nothrow
|
||||
|
||||
// destroy() is called when weak_count_ drops to zero.
|
||||
|
||||
virtual void destroy() // nothrow
|
||||
virtual void destroy() BOOST_SP_NOEXCEPT // nothrow
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_untyped_deleter() = 0;
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
void add_ref_copy()
|
||||
void add_ref_copy() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_increment( &use_count_ );
|
||||
}
|
||||
|
||||
bool add_ref_lock() // true on success
|
||||
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
|
||||
{
|
||||
return atomic_conditional_increment( &use_count_ ) != 0;
|
||||
}
|
||||
|
||||
void release() // nothrow
|
||||
void release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( atomic_decrement( &use_count_ ) == 1 )
|
||||
{
|
||||
@@ -120,12 +122,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void weak_add_ref() // nothrow
|
||||
void weak_add_ref() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_increment( &weak_count_ );
|
||||
}
|
||||
|
||||
void weak_release() // nothrow
|
||||
void weak_release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( atomic_decrement( &weak_count_ ) == 1 )
|
||||
{
|
||||
@@ -133,7 +135,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
long use_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return __c11_atomic_load( const_cast< atomic_int_least32_t* >( &use_count_ ), __ATOMIC_ACQUIRE );
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -91,7 +92,7 @@ store:
|
||||
return a;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -79,7 +80,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -17,6 +17,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -78,7 +79,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -38,7 +39,9 @@ inline void atomic_increment( int * pw )
|
||||
(
|
||||
"0:\n\t"
|
||||
".set push\n\t"
|
||||
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
||||
".set mips2\n\t"
|
||||
#endif
|
||||
"ll %0, %1\n\t"
|
||||
"addiu %0, 1\n\t"
|
||||
"sc %0, %1\n\t"
|
||||
@@ -59,7 +62,9 @@ inline int atomic_decrement( int * pw )
|
||||
(
|
||||
"0:\n\t"
|
||||
".set push\n\t"
|
||||
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
||||
".set mips2\n\t"
|
||||
#endif
|
||||
"ll %1, %2\n\t"
|
||||
"addiu %0, %1, -1\n\t"
|
||||
"sc %0, %2\n\t"
|
||||
@@ -85,7 +90,9 @@ inline int atomic_conditional_increment( int * pw )
|
||||
(
|
||||
"0:\n\t"
|
||||
".set push\n\t"
|
||||
#if !defined(__mips_isa_rev) || (__mips_isa_rev < 6)
|
||||
".set mips2\n\t"
|
||||
#endif
|
||||
"ll %0, %2\n\t"
|
||||
"beqz %0, 1f\n\t"
|
||||
"addiu %1, %0, 1\n\t"
|
||||
@@ -102,7 +109,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -102,7 +103,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
// Thanks to Michael van der Westhuizen
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <inttypes.h> // int32_t
|
||||
|
||||
namespace boost
|
||||
@@ -87,7 +88,7 @@ inline int32_t atomic_conditional_increment( int32_t * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -25,6 +25,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -94,7 +95,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -19,6 +19,9 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -26,55 +29,55 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
sp_counted_base( sp_counted_base const & );
|
||||
sp_counted_base & operator= ( sp_counted_base const & );
|
||||
|
||||
long use_count_; // #shared
|
||||
long weak_count_; // #weak + (#shared != 0)
|
||||
boost::int_least32_t use_count_; // #shared
|
||||
boost::int_least32_t weak_count_; // #weak + (#shared != 0)
|
||||
|
||||
public:
|
||||
|
||||
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
||||
sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~sp_counted_base() // nothrow
|
||||
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
|
||||
{
|
||||
}
|
||||
|
||||
// dispose() is called when use_count_ drops to zero, to release
|
||||
// the resources managed by *this.
|
||||
|
||||
virtual void dispose() = 0; // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT = 0; // nothrow
|
||||
|
||||
// destroy() is called when weak_count_ drops to zero.
|
||||
|
||||
virtual void destroy() // nothrow
|
||||
virtual void destroy() BOOST_SP_NOEXCEPT // nothrow
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_untyped_deleter() = 0;
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
void add_ref_copy()
|
||||
void add_ref_copy() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
++use_count_;
|
||||
}
|
||||
|
||||
bool add_ref_lock() // true on success
|
||||
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
|
||||
{
|
||||
if( use_count_ == 0 ) return false;
|
||||
++use_count_;
|
||||
return true;
|
||||
}
|
||||
|
||||
void release() // nothrow
|
||||
void release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( --use_count_ == 0 )
|
||||
{
|
||||
@@ -83,12 +86,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void weak_add_ref() // nothrow
|
||||
void weak_add_ref() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
++weak_count_;
|
||||
}
|
||||
|
||||
void weak_release() // nothrow
|
||||
void weak_release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( --weak_count_ == 0 )
|
||||
{
|
||||
@@ -96,7 +99,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
long use_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return use_count_;
|
||||
}
|
||||
|
@@ -20,6 +20,8 @@
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <pthread.h>
|
||||
|
||||
namespace boost
|
||||
@@ -28,15 +30,15 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
sp_counted_base( sp_counted_base const & );
|
||||
sp_counted_base & operator= ( sp_counted_base const & );
|
||||
|
||||
long use_count_; // #shared
|
||||
long weak_count_; // #weak + (#shared != 0)
|
||||
boost::int_least32_t use_count_; // #shared
|
||||
boost::int_least32_t weak_count_; // #weak + (#shared != 0)
|
||||
|
||||
mutable pthread_mutex_t m_;
|
||||
|
||||
@@ -92,7 +94,7 @@ public:
|
||||
void release() // nothrow
|
||||
{
|
||||
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
|
||||
long new_use_count = --use_count_;
|
||||
boost::int_least32_t new_use_count = --use_count_;
|
||||
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
|
||||
|
||||
if( new_use_count == 0 )
|
||||
@@ -112,7 +114,7 @@ public:
|
||||
void weak_release() // nothrow
|
||||
{
|
||||
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
|
||||
long new_weak_count = --weak_count_;
|
||||
boost::int_least32_t new_weak_count = --weak_count_;
|
||||
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
|
||||
|
||||
if( new_weak_count == 0 )
|
||||
@@ -124,7 +126,7 @@ public:
|
||||
long use_count() const // nothrow
|
||||
{
|
||||
BOOST_VERIFY( pthread_mutex_lock( &m_ ) == 0 );
|
||||
long r = use_count_;
|
||||
boost::int_least32_t r = use_count_;
|
||||
BOOST_VERIFY( pthread_mutex_unlock( &m_ ) == 0 );
|
||||
|
||||
return r;
|
||||
|
@@ -20,6 +20,7 @@
|
||||
// Thanks to Michael van der Westhuizen
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <inttypes.h> // uint32_t
|
||||
|
||||
namespace boost
|
||||
@@ -82,7 +83,7 @@ inline uint32_t atomic_conditional_increment( uint32_t * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <atomic.h>
|
||||
|
||||
namespace boost
|
||||
@@ -29,7 +30,7 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/smart_ptr/detail/spinlock_pool.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -51,7 +52,7 @@ inline int atomic_conditional_increment( int * pw )
|
||||
return rv;
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -16,6 +16,8 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -25,17 +27,17 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
inline void atomic_increment( std::atomic_int_least32_t * pw )
|
||||
inline void atomic_increment( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
pw->fetch_add( 1, std::memory_order_relaxed );
|
||||
}
|
||||
|
||||
inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw )
|
||||
inline std::int_least32_t atomic_decrement( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pw->fetch_sub( 1, std::memory_order_acq_rel );
|
||||
}
|
||||
|
||||
inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw )
|
||||
inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_t * pw ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
// long r = *pw;
|
||||
// if( r != 0 ) ++*pw;
|
||||
@@ -57,7 +59,7 @@ inline std::int_least32_t atomic_conditional_increment( std::atomic_int_least32_
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -69,41 +71,41 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
sp_counted_base(): use_count_( 1 ), weak_count_( 1 )
|
||||
sp_counted_base() BOOST_SP_NOEXCEPT: use_count_( 1 ), weak_count_( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~sp_counted_base() // nothrow
|
||||
virtual ~sp_counted_base() /*BOOST_SP_NOEXCEPT*/
|
||||
{
|
||||
}
|
||||
|
||||
// dispose() is called when use_count_ drops to zero, to release
|
||||
// the resources managed by *this.
|
||||
|
||||
virtual void dispose() = 0; // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
// destroy() is called when weak_count_ drops to zero.
|
||||
|
||||
virtual void destroy() // nothrow
|
||||
virtual void destroy() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) = 0;
|
||||
virtual void * get_untyped_deleter() = 0;
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT = 0;
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT = 0;
|
||||
|
||||
void add_ref_copy()
|
||||
void add_ref_copy() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_increment( &use_count_ );
|
||||
}
|
||||
|
||||
bool add_ref_lock() // true on success
|
||||
bool add_ref_lock() BOOST_SP_NOEXCEPT // true on success
|
||||
{
|
||||
return atomic_conditional_increment( &use_count_ ) != 0;
|
||||
}
|
||||
|
||||
void release() // nothrow
|
||||
void release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( atomic_decrement( &use_count_ ) == 1 )
|
||||
{
|
||||
@@ -112,12 +114,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void weak_add_ref() // nothrow
|
||||
void weak_add_ref() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_increment( &weak_count_ );
|
||||
}
|
||||
|
||||
void weak_release() // nothrow
|
||||
void weak_release() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
if( atomic_decrement( &weak_count_ ) == 1 )
|
||||
{
|
||||
@@ -125,7 +127,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
long use_count() const // nothrow
|
||||
long use_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return use_count_.load( std::memory_order_acquire );
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <limits.h>
|
||||
|
||||
#if defined( __ia64__ ) && defined( __INTEL_COMPILER )
|
||||
@@ -76,7 +77,7 @@ inline sp_int32_t atomic_conditional_increment( sp_int32_t * pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -22,6 +22,7 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
extern "builtin" void __lwsync(void);
|
||||
extern "builtin" void __isync(void);
|
||||
@@ -70,7 +71,7 @@ inline int atomic_conditional_increment( int *pw )
|
||||
}
|
||||
}
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -27,6 +27,7 @@
|
||||
#include <boost/smart_ptr/detail/sp_interlocked.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -34,7 +35,7 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class sp_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <boost/checked_delete.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_counted_base.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
|
||||
#if defined(BOOST_SP_USE_QUICK_ALLOCATOR)
|
||||
@@ -55,16 +56,16 @@ namespace detail
|
||||
|
||||
template<class D> class local_sp_deleter;
|
||||
|
||||
template<class D> D * get_local_deleter( D * /*p*/ )
|
||||
template<class D> D * get_local_deleter( D * /*p*/ ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class D> D * get_local_deleter( local_sp_deleter<D> * p );
|
||||
template<class D> D * get_local_deleter( local_sp_deleter<D> * p ) BOOST_SP_NOEXCEPT;
|
||||
|
||||
//
|
||||
|
||||
template<class X> class sp_counted_impl_p: public sp_counted_base
|
||||
template<class X> class BOOST_SYMBOL_VISIBLE sp_counted_impl_p: public sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -84,7 +85,7 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void dispose() // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
|
||||
boost::sp_scalar_destructor_hook( px_, sizeof(X), this );
|
||||
@@ -92,17 +93,17 @@ public:
|
||||
boost::checked_delete( px_ );
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & )
|
||||
virtual void * get_deleter( sp_typeinfo const & ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void * get_local_deleter( sp_typeinfo const & )
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void * get_untyped_deleter()
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -143,7 +144,7 @@ public:
|
||||
# pragma option push -Vx-
|
||||
#endif
|
||||
|
||||
template<class P, class D> class sp_counted_impl_pd: public sp_counted_base
|
||||
template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -167,22 +168,22 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void dispose() // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
del( ptr );
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & ti )
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return ti == BOOST_SP_TYPEID(D)? &reinterpret_cast<char&>( del ): 0;
|
||||
}
|
||||
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti )
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( boost::addressof( del ) ): 0;
|
||||
}
|
||||
|
||||
virtual void * get_untyped_deleter()
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return &reinterpret_cast<char&>( del );
|
||||
}
|
||||
@@ -216,7 +217,7 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class P, class D, class A> class sp_counted_impl_pda: public sp_counted_base
|
||||
template<class P, class D, class A> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pda: public sp_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -241,12 +242,12 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void dispose() // nothrow
|
||||
virtual void dispose() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
d_( p_ );
|
||||
}
|
||||
|
||||
virtual void destroy() // nothrow
|
||||
virtual void destroy() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
#if !defined( BOOST_NO_CXX11_ALLOCATOR )
|
||||
|
||||
@@ -265,17 +266,17 @@ public:
|
||||
a2.deallocate( this, 1 );
|
||||
}
|
||||
|
||||
virtual void * get_deleter( sp_typeinfo const & ti )
|
||||
virtual void * get_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return ti == BOOST_SP_TYPEID( D )? &reinterpret_cast<char&>( d_ ): 0;
|
||||
}
|
||||
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti )
|
||||
virtual void * get_local_deleter( sp_typeinfo const & ti ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return ti == BOOST_SP_TYPEID(D)? boost::detail::get_local_deleter( boost::addressof( d_ ) ): 0;
|
||||
}
|
||||
|
||||
virtual void * get_untyped_deleter()
|
||||
virtual void * get_untyped_deleter() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return &reinterpret_cast<char&>( d_ );
|
||||
}
|
||||
|
@@ -32,11 +32,21 @@
|
||||
// MinGW-w64 provides intrin.h for both 32 and 64-bit targets.
|
||||
# define BOOST_SP_HAS_INTRIN_H
|
||||
|
||||
#elif defined( __LP64__ )
|
||||
|
||||
// We have to use intrin.h on Cygwin 64
|
||||
# define BOOST_SP_HAS_INTRIN_H
|
||||
|
||||
// Intel C++ on Windows on VC10+ stdlib
|
||||
#elif defined( BOOST_INTEL_WIN ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
|
||||
|
||||
# define BOOST_SP_HAS_INTRIN_H
|
||||
|
||||
// clang-cl on Windows on VC10+ stdlib
|
||||
#elif defined( __clang__ ) && defined( _MSC_VER ) && defined( _CPPLIB_VER ) && _CPPLIB_VER >= 520
|
||||
|
||||
# define BOOST_SP_HAS_INTRIN_H
|
||||
|
||||
#endif
|
||||
|
||||
#if defined( BOOST_USE_WINDOWS_H )
|
||||
|
@@ -16,6 +16,7 @@
|
||||
//
|
||||
|
||||
#include <boost/smart_ptr/detail/yield_k.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <atomic>
|
||||
|
||||
namespace boost
|
||||
@@ -32,12 +33,12 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
bool try_lock()
|
||||
bool try_lock() BOOST_NOEXCEPT
|
||||
{
|
||||
return !v_.test_and_set( std::memory_order_acquire );
|
||||
}
|
||||
|
||||
void lock()
|
||||
void lock() BOOST_NOEXCEPT
|
||||
{
|
||||
for( unsigned k = 0; !try_lock(); ++k )
|
||||
{
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void unlock()
|
||||
void unlock() BOOST_NOEXCEPT
|
||||
{
|
||||
v_ .clear( std::memory_order_release );
|
||||
}
|
||||
@@ -63,12 +64,12 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
explicit scoped_lock( spinlock & sp ): sp_( sp )
|
||||
explicit scoped_lock( spinlock & sp ) BOOST_NOEXCEPT: sp_( sp )
|
||||
{
|
||||
sp.lock();
|
||||
}
|
||||
|
||||
~scoped_lock()
|
||||
~scoped_lock() /*BOOST_NOEXCEPT*/
|
||||
{
|
||||
sp_.unlock();
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef.h>
|
||||
#include <boost/predef/platform/windows_runtime.h>
|
||||
|
||||
#if BOOST_PLAT_WINDOWS_RUNTIME
|
||||
#include <thread>
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
// BOOST_SMT_PAUSE
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) )
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) && !defined(__c2__)
|
||||
|
||||
extern "C" void _mm_pause();
|
||||
|
||||
@@ -60,19 +60,25 @@ namespace detail
|
||||
{
|
||||
|
||||
#if !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
|
||||
#if !BOOST_COMP_CLANG || !defined __MINGW32__
|
||||
extern "C" void __stdcall Sleep( unsigned long ms );
|
||||
|
||||
#if defined(__clang__) && defined(__x86_64__)
|
||||
// clang x64 warns that __stdcall is ignored
|
||||
# define BOOST_SP_STDCALL
|
||||
#else
|
||||
#include <_mingw.h>
|
||||
#if !defined __MINGW64_VERSION_MAJOR
|
||||
extern "C" void __stdcall Sleep( unsigned long ms );
|
||||
#else
|
||||
extern "C" __declspec(dllimport) void __stdcall Sleep( unsigned long ms );
|
||||
#endif
|
||||
#endif
|
||||
# define BOOST_SP_STDCALL __stdcall
|
||||
#endif
|
||||
|
||||
inline void yield( unsigned k )
|
||||
#if defined(__LP64__) // Cygwin 64
|
||||
extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned int ms );
|
||||
#else
|
||||
extern "C" __declspec(dllimport) void BOOST_SP_STDCALL Sleep( unsigned long ms );
|
||||
#endif
|
||||
|
||||
#undef BOOST_SP_STDCALL
|
||||
|
||||
#endif // !defined( BOOST_USE_WINDOWS_H ) && !BOOST_PLAT_WINDOWS_RUNTIME
|
||||
|
||||
inline void yield( unsigned k ) BOOST_NOEXCEPT
|
||||
{
|
||||
if( k < 4 )
|
||||
{
|
||||
|
@@ -149,7 +149,7 @@ public:
|
||||
#endif
|
||||
|
||||
// internal constructor, used by make_shared
|
||||
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, T * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
|
||||
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, element_type * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -1,63 +1,73 @@
|
||||
#ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP_INCLUDED
|
||||
#define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP_INCLUDED
|
||||
/*
|
||||
Copyright 2017 Peter Dimov
|
||||
Copyright 2017-2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
// make_local_shared_array.hpp
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
// See http://www.boost.org/libs/smart_ptr/ for documentation.
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
|
||||
#define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <utility>
|
||||
#include <cstddef>
|
||||
#include <boost/smart_ptr/allocate_local_shared_array.hpp>
|
||||
|
||||
namespace boost
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared()
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct lsp_if_array
|
||||
{
|
||||
};
|
||||
|
||||
template<class T> struct lsp_if_array<T[]>
|
||||
{
|
||||
typedef boost::local_shared_ptr<T[]> type;
|
||||
};
|
||||
|
||||
template<class T, std::size_t N> struct lsp_if_array<T[N]>
|
||||
{
|
||||
typedef boost::local_shared_ptr<T[N]> type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template<class T, class... Args> typename boost::detail::lsp_if_array<T>::type make_local_shared( Args&&... args )
|
||||
{
|
||||
return boost::make_shared<T>( std::forward<Args>(args)... );
|
||||
return boost::allocate_local_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>());
|
||||
}
|
||||
|
||||
template<class T, class... Args> typename boost::detail::lsp_if_array<T>::type make_local_shared_noinit( Args&&... args )
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(const typename remove_extent<T>::type& value)
|
||||
{
|
||||
return boost::make_shared_noinit<T>( std::forward<Args>(args)... );
|
||||
return boost::allocate_local_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), value);
|
||||
}
|
||||
|
||||
template<class T, class A, class... Args> typename boost::detail::lsp_if_array<T>::type allocate_local_shared( A const & a, Args&&... args )
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(std::size_t size)
|
||||
{
|
||||
return boost::allocate_shared<T>( a, std::forward<Args>(args)... );
|
||||
return boost::allocate_local_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), size);
|
||||
}
|
||||
|
||||
template<class T, class A, class... Args> typename boost::detail::lsp_if_array<T>::type allocate_local_shared_noinit( A const & a, Args&&... args )
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared(std::size_t size,
|
||||
const typename remove_extent<T>::type& value)
|
||||
{
|
||||
return boost::allocate_shared_noinit<T>( a, std::forward<Args>(args)... );
|
||||
return boost::allocate_local_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), size, value);
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
template<class T>
|
||||
inline typename enable_if_<is_bounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared_noinit()
|
||||
{
|
||||
return boost::allocate_local_shared_noinit<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>());
|
||||
}
|
||||
|
||||
#endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED
|
||||
template<class T>
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
local_shared_ptr<T> >::type
|
||||
make_local_shared_noinit(std::size_t size)
|
||||
{
|
||||
return boost::allocate_local_shared_noinit<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), size);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
||||
#endif
|
||||
|
@@ -13,6 +13,7 @@
|
||||
|
||||
#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 <utility>
|
||||
#include <cstddef>
|
||||
@@ -165,7 +166,7 @@ template<class T, class A> typename boost::detail::lsp_if_not_array<T>::type all
|
||||
|
||||
A2 a2( a );
|
||||
|
||||
typedef boost::detail::lsp_ms_deleter<T, A2> D;
|
||||
typedef boost::detail::lsp_ms_deleter< T, std::allocator<T> > D;
|
||||
|
||||
boost::shared_ptr<T> pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a2 );
|
||||
|
||||
@@ -186,12 +187,14 @@ 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 )
|
||||
{
|
||||
return boost::allocate_local_shared<T>( std::allocator<T>(), std::forward<Args>(args)... );
|
||||
typedef typename boost::remove_const<T>::type T2;
|
||||
return boost::allocate_local_shared<T2>( std::allocator<T2>(), std::forward<Args>(args)... );
|
||||
}
|
||||
|
||||
template<class T> typename boost::detail::lsp_if_not_array<T>::type make_local_shared_noinit()
|
||||
{
|
||||
return boost::allocate_shared_noinit<T>( std::allocator<T>() );
|
||||
typedef typename boost::remove_const<T>::type T2;
|
||||
return boost::allocate_shared_noinit<T2>( std::allocator<T2>() );
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2012-2017 Glen Joseph Fernandes
|
||||
Copyright 2012-2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -13,7 +13,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
namespace boost {
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared()
|
||||
{
|
||||
return boost::allocate_shared<T>(std::allocator<typename
|
||||
@@ -21,15 +21,15 @@ make_shared()
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
make_shared(const typename detail::sp_array_element<T>::type& value)
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared(const typename remove_extent<T>::type& value)
|
||||
{
|
||||
return boost::allocate_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), value);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_array<T>::type
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared(std::size_t size)
|
||||
{
|
||||
return boost::allocate_shared<T>(std::allocator<typename
|
||||
@@ -37,27 +37,26 @@ make_shared(std::size_t size)
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_array<T>::type
|
||||
make_shared(std::size_t size,
|
||||
const typename detail::sp_array_element<T>::type& value)
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared(std::size_t size, const typename remove_extent<T>::type& value)
|
||||
{
|
||||
return boost::allocate_shared<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), size, value);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_size_array<T>::type
|
||||
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared_noinit()
|
||||
{
|
||||
return allocate_shared_noinit<T>(std::allocator<typename
|
||||
return boost::allocate_shared_noinit<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::sp_if_array<T>::type
|
||||
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
||||
make_shared_noinit(std::size_t size)
|
||||
{
|
||||
return allocate_shared_noinit<T>(std::allocator<typename
|
||||
return boost::allocate_shared_noinit<T>(std::allocator<typename
|
||||
detail::sp_array_scalar<T>::type>(), size);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2012-2015 Glen Joseph Fernandes
|
||||
Copyright 2012-2019 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -8,59 +8,18 @@ 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/config.hpp>
|
||||
#include <boost/type_traits/enable_if.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_unbounded_array.hpp>
|
||||
#include <boost/type_traits/remove_extent.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
|
||||
template<class T>
|
||||
struct up_if_object {
|
||||
typedef std::unique_ptr<T> type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct up_if_object<T[]> { };
|
||||
|
||||
template<class T, std::size_t N>
|
||||
struct up_if_object<T[N]> { };
|
||||
|
||||
template<class T>
|
||||
struct up_if_array { };
|
||||
|
||||
template<class T>
|
||||
struct up_if_array<T[]> {
|
||||
typedef std::unique_ptr<T[]> type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct up_remove_reference {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct up_remove_reference<T&> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct up_remove_reference<T&&> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct up_element { };
|
||||
|
||||
template<class T>
|
||||
struct up_element<T[]> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
} /* detail */
|
||||
|
||||
template<class T>
|
||||
inline typename detail::up_if_object<T>::type
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique()
|
||||
{
|
||||
return std::unique_ptr<T>(new T());
|
||||
@@ -68,7 +27,7 @@ make_unique()
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<class T, class... Args>
|
||||
inline typename detail::up_if_object<T>::type
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique(Args&&... args)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
@@ -76,33 +35,33 @@ make_unique(Args&&... args)
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
inline typename detail::up_if_object<T>::type
|
||||
make_unique(typename detail::up_remove_reference<T>::type&& value)
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique(typename remove_reference<T>::type&& value)
|
||||
{
|
||||
return std::unique_ptr<T>(new T(std::move(value)));
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::up_if_object<T>::type
|
||||
inline typename enable_if_<!is_array<T>::value, std::unique_ptr<T> >::type
|
||||
make_unique_noinit()
|
||||
{
|
||||
return std::unique_ptr<T>(new T);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::up_if_array<T>::type
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
std::unique_ptr<T> >::type
|
||||
make_unique(std::size_t size)
|
||||
{
|
||||
return std::unique_ptr<T>(new typename
|
||||
detail::up_element<T>::type[size]());
|
||||
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline typename detail::up_if_array<T>::type
|
||||
inline typename enable_if_<is_unbounded_array<T>::value,
|
||||
std::unique_ptr<T> >::type
|
||||
make_unique_noinit(std::size_t size)
|
||||
{
|
||||
return std::unique_ptr<T>(new typename
|
||||
detail::up_element<T>::type[size]);
|
||||
return std::unique_ptr<T>(new typename remove_extent<T>::type[size]);
|
||||
}
|
||||
|
||||
} /* boost */
|
||||
|
@@ -797,7 +797,7 @@ public:
|
||||
return px == r.px && pn == r.pn;
|
||||
}
|
||||
|
||||
boost::detail::shared_count _internal_count() const BOOST_NOEXCEPT
|
||||
boost::detail::shared_count _internal_count() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pn;
|
||||
}
|
||||
@@ -1022,7 +1022,7 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
esft2_deleter_wrapper()
|
||||
esft2_deleter_wrapper() BOOST_SP_NOEXCEPT
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1080,7 +1080,7 @@ template<class T> shared_ptr<T> atomic_load( shared_ptr<T> const * p ) BOOST_SP_
|
||||
return *p;
|
||||
}
|
||||
|
||||
template<class T> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline shared_ptr<T> atomic_load_explicit( shared_ptr<T> const * p, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_load( p );
|
||||
}
|
||||
@@ -1091,7 +1091,7 @@ template<class T> void atomic_store( shared_ptr<T> * p, shared_ptr<T> r ) BOOST_
|
||||
p->swap( r );
|
||||
}
|
||||
|
||||
template<class T> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline void atomic_store_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
atomic_store( p, r ); // std::move( r )
|
||||
}
|
||||
@@ -1107,7 +1107,7 @@ template<class T> shared_ptr<T> atomic_exchange( shared_ptr<T> * p, shared_ptr<T
|
||||
return r; // return std::move( r )
|
||||
}
|
||||
|
||||
template<class T> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> shared_ptr<T> inline atomic_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> r, /*memory_order mo*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_exchange( p, r ); // std::move( r )
|
||||
}
|
||||
@@ -1137,7 +1137,7 @@ template<class T> bool atomic_compare_exchange( shared_ptr<T> * p, shared_ptr<T>
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ int, /*memory_order failure*/ int ) BOOST_SP_NOEXCEPT
|
||||
template<class T, class M> inline bool atomic_compare_exchange_explicit( shared_ptr<T> * p, shared_ptr<T> * v, shared_ptr<T> w, /*memory_order success*/ M, /*memory_order failure*/ M ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return atomic_compare_exchange( p, v, w ); // std::move( w )
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@
|
||||
"Glen Fernandes"
|
||||
],
|
||||
"description": "Smart pointer class templates.",
|
||||
"documentation": "smart_ptr.htm",
|
||||
"std": [
|
||||
"tr1"
|
||||
],
|
||||
|
308
test/Jamfile
Normal file
308
test/Jamfile
Normal file
@@ -0,0 +1,308 @@
|
||||
# Boost.SmartPtr Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003-2018 Peter Dimov
|
||||
# Copyright (c) 2003 Dave Abrahams
|
||||
#
|
||||
# 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)
|
||||
|
||||
import testing ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<toolset>gcc:<cxxflags>-Wno-non-virtual-dtor
|
||||
<toolset>gcc:<cxxflags>-Wno-deprecated-declarations
|
||||
#<toolset>gcc:<cxxflags>-Wno-delete-non-virtual-dtor (not in 4.4/4.6)
|
||||
;
|
||||
|
||||
# quick test (for CI)
|
||||
run quick.cpp ;
|
||||
|
||||
# full test suite
|
||||
run smart_ptr_test.cpp ;
|
||||
run shared_ptr_basic_test.cpp ;
|
||||
run shared_ptr_test.cpp ;
|
||||
run weak_ptr_test.cpp ;
|
||||
run weak_ptr_move_test.cpp ;
|
||||
run shared_from_this_test.cpp ;
|
||||
run get_deleter_test.cpp ;
|
||||
run intrusive_ptr_test.cpp ;
|
||||
run intrusive_ptr_move_test.cpp ;
|
||||
run intrusive_ref_counter_test.cpp ;
|
||||
run atomic_count_test.cpp ;
|
||||
run lw_mutex_test.cpp ;
|
||||
run lw_mutex_test.cpp : : : <define>BOOST_USE_WINDOWS_H : lw_mutex_test.win_h ;
|
||||
compile-fail shared_ptr_assign_fail.cpp ;
|
||||
compile-fail shared_ptr_delete_fail.cpp ;
|
||||
compile-fail shared_ptr_compare_fail.cpp ;
|
||||
run shared_ptr_alloc2_test.cpp ;
|
||||
run pointer_cast_test.cpp ;
|
||||
run cpp11_pointer_cast_test.cpp ;
|
||||
compile pointer_to_other_test.cpp ;
|
||||
run auto_ptr_rv_test.cpp ;
|
||||
run shared_ptr_alias_test.cpp ;
|
||||
run shared_ptr_rv_test.cpp ;
|
||||
run shared_ptr_rv_pointer_cast_test.cpp ;
|
||||
run shared_ptr_move_test.cpp ;
|
||||
run shared_ptr_alias_move_test.cpp ;
|
||||
run shared_ptr_reinterpret_pointer_cast_test.cpp ;
|
||||
compile-fail shared_ptr_pv_fail.cpp ;
|
||||
run sp_unary_addr_test.cpp ;
|
||||
compile-fail scoped_ptr_eq_fail.cpp ;
|
||||
compile-fail scoped_array_eq_fail.cpp ;
|
||||
run esft_regtest.cpp ;
|
||||
run yield_k_test.cpp ;
|
||||
run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ;
|
||||
run spinlock_test.cpp ;
|
||||
run spinlock_try_test.cpp ;
|
||||
run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ;
|
||||
run spinlock_pool_test.cpp : : :
|
||||
# msvc-8.0, 9.0 optimizer codegen bug for `x % 41`
|
||||
<toolset>msvc-8.0,<variant>release:<build>no
|
||||
<toolset>msvc-9.0,<variant>release:<build>no ;
|
||||
|
||||
run make_shared_test.cpp ;
|
||||
run make_shared_move_emulation_test.cpp ;
|
||||
run make_shared_perfect_forwarding_test.cpp ;
|
||||
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 ;
|
||||
run esft_void_test.cpp ;
|
||||
run esft_second_ptr_test.cpp ;
|
||||
run make_shared_esft_test.cpp ;
|
||||
run allocate_shared_esft_test.cpp ;
|
||||
run sp_recursive_assign_test.cpp ;
|
||||
run sp_recursive_assign2_test.cpp ;
|
||||
run sp_recursive_assign_rv_test.cpp ;
|
||||
run sp_recursive_assign2_rv_test.cpp ;
|
||||
compile-fail auto_ptr_lv_fail.cpp : <toolset>gcc-4.4.7:<build>no ;
|
||||
run atomic_count_test2.cpp ;
|
||||
run sp_typeinfo_test.cpp ;
|
||||
compile make_shared_fp_test.cpp ;
|
||||
run sp_hash_test.cpp ;
|
||||
run get_deleter_array_test.cpp ;
|
||||
run ip_hash_test.cpp ;
|
||||
run owner_less_test.cpp ;
|
||||
run sp_unique_ptr_test.cpp ;
|
||||
run sp_array_test.cpp ;
|
||||
compile sp_array_cv_test.cpp ;
|
||||
run sp_convertible_test.cpp ;
|
||||
run sp_array_n_test.cpp ;
|
||||
run sp_array_cast_test.cpp ;
|
||||
run sp_zero_compare_test.cpp ;
|
||||
run sp_nullptr_test.cpp ;
|
||||
run sa_nullptr_test.cpp ;
|
||||
run shared_ptr_alloc3_test.cpp ;
|
||||
run shared_ptr_alloc11_test.cpp ;
|
||||
run shared_ptr_alloc_construct11_test.cpp ;
|
||||
run allocate_shared_alloc11_test.cpp ;
|
||||
run allocate_shared_construct11_test.cpp ;
|
||||
run sp_interlocked_test.cpp ;
|
||||
|
||||
compile-fail array_fail_spa_sp_c.cpp ;
|
||||
compile-fail array_fail_sp_spa_c.cpp ;
|
||||
compile-fail array_fail_spa_spa_c.cpp ;
|
||||
compile-fail array_fail_spa_wp_c.cpp ;
|
||||
compile-fail array_fail_sp_wpa_c.cpp ;
|
||||
compile-fail array_fail_spa_wpa_c.cpp ;
|
||||
compile-fail array_fail_wpa_wp_c.cpp ;
|
||||
compile-fail array_fail_wp_wpa_c.cpp ;
|
||||
compile-fail array_fail_wpa_wpa_c.cpp ;
|
||||
compile-fail array_fail_ap_spa_c.cpp ;
|
||||
compile-fail array_fail_upa_sp_c.cpp ;
|
||||
compile-fail array_fail_up_spa_c.cpp ;
|
||||
|
||||
compile-fail array_fail_spa_sp_mc.cpp ;
|
||||
compile-fail array_fail_sp_spa_mc.cpp ;
|
||||
compile-fail array_fail_spa_spa_mc.cpp ;
|
||||
compile-fail array_fail_spa_wp_mc.cpp ;
|
||||
compile-fail array_fail_sp_wpa_mc.cpp ;
|
||||
compile-fail array_fail_spa_wpa_mc.cpp ;
|
||||
compile-fail array_fail_wpa_wp_mc.cpp ;
|
||||
compile-fail array_fail_wp_wpa_mc.cpp ;
|
||||
compile-fail array_fail_wpa_wpa_mc.cpp ;
|
||||
compile-fail array_fail_ap_spa_mc.cpp ;
|
||||
compile-fail array_fail_upa_sp_mc.cpp ;
|
||||
compile-fail array_fail_up_spa_mc.cpp ;
|
||||
|
||||
compile-fail array_fail_spa_sp_a.cpp ;
|
||||
compile-fail array_fail_sp_spa_a.cpp ;
|
||||
compile-fail array_fail_spa_spa_a.cpp ;
|
||||
compile-fail array_fail_spa_wp_a.cpp ;
|
||||
compile-fail array_fail_sp_wpa_a.cpp ;
|
||||
compile-fail array_fail_spa_wpa_a.cpp ;
|
||||
compile-fail array_fail_wpa_wp_a.cpp ;
|
||||
compile-fail array_fail_wp_wpa_a.cpp ;
|
||||
compile-fail array_fail_wpa_wpa_a.cpp ;
|
||||
compile-fail array_fail_ap_spa_a.cpp ;
|
||||
compile-fail array_fail_upa_sp_a.cpp ;
|
||||
compile-fail array_fail_up_spa_a.cpp ;
|
||||
|
||||
compile-fail array_fail_spa_sp_ma.cpp ;
|
||||
compile-fail array_fail_sp_spa_ma.cpp ;
|
||||
compile-fail array_fail_spa_spa_ma.cpp ;
|
||||
compile-fail array_fail_spa_wp_ma.cpp ;
|
||||
compile-fail array_fail_sp_wpa_ma.cpp ;
|
||||
compile-fail array_fail_spa_wpa_ma.cpp ;
|
||||
compile-fail array_fail_wpa_wp_ma.cpp ;
|
||||
compile-fail array_fail_wp_wpa_ma.cpp ;
|
||||
compile-fail array_fail_wpa_wpa_ma.cpp ;
|
||||
compile-fail array_fail_ap_spa_ma.cpp ;
|
||||
compile-fail array_fail_upa_sp_ma.cpp ;
|
||||
compile-fail array_fail_up_spa_ma.cpp ;
|
||||
|
||||
compile-fail array_fail_dereference.cpp ;
|
||||
compile-fail array_fail_member_access.cpp ;
|
||||
compile-fail array_fail_array_access.cpp ;
|
||||
|
||||
run make_shared_array_test.cpp ;
|
||||
run make_shared_arrays_test.cpp ; # <cxxflags>-fno-deduce-init-list no longer needed for gcc-4.6
|
||||
run make_shared_array_throws_test.cpp ;
|
||||
run make_shared_array_esft_test.cpp ;
|
||||
run make_shared_array_noinit_test.cpp ;
|
||||
run make_shared_array_value_test.cpp ;
|
||||
run allocate_shared_array_test.cpp ;
|
||||
run allocate_shared_arrays_test.cpp ; # <cxxflags>-fno-deduce-init-list no longer needed for gcc-4.6
|
||||
run allocate_shared_array_throws_test.cpp ;
|
||||
run allocate_shared_array_esft_test.cpp ;
|
||||
run allocate_shared_array_noinit_test.cpp ;
|
||||
run allocate_shared_array_value_test.cpp ;
|
||||
run allocate_shared_array_construct_test.cpp ;
|
||||
|
||||
run make_unique_test.cpp ;
|
||||
run make_unique_args_test.cpp ;
|
||||
run make_unique_value_test.cpp : : : <toolset>gcc-4.6:<cxxflags>-fno-deduce-init-list ;
|
||||
run make_unique_noinit_test.cpp ;
|
||||
run make_unique_throws_test.cpp ;
|
||||
run make_unique_array_test.cpp ;
|
||||
run make_unique_array_noinit_test.cpp ;
|
||||
run make_unique_array_throws_test.cpp ;
|
||||
|
||||
run shared_from_raw_test.cpp ;
|
||||
run shared_from_raw_test2.cpp ;
|
||||
run shared_from_raw_test3.cpp ;
|
||||
run shared_from_raw_test4.cpp ;
|
||||
run shared_from_raw_test5.cpp ;
|
||||
run shared_from_raw_test6.cpp ;
|
||||
|
||||
run weak_from_raw_test.cpp ;
|
||||
run weak_from_raw_test2.cpp ;
|
||||
run weak_from_raw_test3.cpp ;
|
||||
run weak_from_raw_test4.cpp ;
|
||||
run weak_from_raw_test5.cpp ;
|
||||
|
||||
compile sp_explicit_inst_test.cpp ;
|
||||
|
||||
run weak_from_this_test.cpp ;
|
||||
run weak_from_this_test2.cpp ;
|
||||
|
||||
run sp_bml_unique_ptr_test.cpp ;
|
||||
|
||||
run sp_hash_test2.cpp ;
|
||||
run sp_hash_test3.cpp ;
|
||||
|
||||
run pointer_cast_test2.cpp ;
|
||||
|
||||
compile-fail pointer_cast_st_fail.cpp ;
|
||||
compile-fail pointer_cast_st_fail2.cpp ;
|
||||
compile-fail pointer_cast_st_fail3.cpp ;
|
||||
|
||||
compile-fail pointer_cast_co_fail.cpp ;
|
||||
compile-fail pointer_cast_co_fail2.cpp ;
|
||||
compile-fail pointer_cast_co_fail3.cpp ;
|
||||
|
||||
compile-fail pointer_cast_dy_fail.cpp ;
|
||||
compile-fail pointer_cast_dy_fail2.cpp ;
|
||||
compile-fail pointer_cast_dy_fail3.cpp ;
|
||||
|
||||
run sp_nothrow_test.cpp ;
|
||||
|
||||
compile make_shared_msvc_test.cpp ;
|
||||
|
||||
compile lwm_win32_cs_test.cpp ;
|
||||
|
||||
run atomic_sp_test.cpp ;
|
||||
|
||||
run sp_constexpr_test.cpp ;
|
||||
run sp_constexpr_test2.cpp ;
|
||||
|
||||
run atomic_sp_constexpr_test.cpp ;
|
||||
|
||||
run shared_ptr_fn_test.cpp ;
|
||||
|
||||
run get_deleter_test2.cpp ;
|
||||
run get_deleter_test3.cpp ;
|
||||
run get_deleter_array_test2.cpp ;
|
||||
run get_deleter_array_test3.cpp ;
|
||||
|
||||
run sp_convertible_test2.cpp ;
|
||||
|
||||
run local_sp_test.cpp ;
|
||||
run lsp_array_test.cpp ;
|
||||
run lsp_array_n_test.cpp ;
|
||||
run lsp_array_cv_test.cpp ;
|
||||
run lsp_array_cast_test.cpp ;
|
||||
|
||||
run get_local_deleter_test.cpp ;
|
||||
run get_local_deleter_test2.cpp ;
|
||||
run get_local_deleter_test3.cpp ;
|
||||
run get_local_deleter_array_test.cpp ;
|
||||
run get_local_deleter_array_test2.cpp ;
|
||||
|
||||
run make_local_shared_test.cpp ;
|
||||
run make_local_shared_esft_test.cpp ;
|
||||
run allocate_local_shared_test.cpp ;
|
||||
run allocate_local_shared_esft_test.cpp ;
|
||||
|
||||
run make_local_shared_array_test.cpp ;
|
||||
run make_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
|
||||
run make_local_shared_array_throws_test.cpp ;
|
||||
run make_local_shared_array_esft_test.cpp ;
|
||||
run make_local_shared_array_noinit_test.cpp ;
|
||||
run make_local_shared_array_value_test.cpp ;
|
||||
run allocate_local_shared_array_test.cpp ;
|
||||
run allocate_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
|
||||
run allocate_local_shared_array_throws_test.cpp ;
|
||||
run allocate_local_shared_array_esft_test.cpp ;
|
||||
run allocate_local_shared_array_noinit_test.cpp ;
|
||||
run allocate_local_shared_array_value_test.cpp ;
|
||||
run allocate_local_shared_array_construct_test.cpp ;
|
||||
|
||||
run local_sp_fn_test.cpp ;
|
||||
run lsp_convertible_test.cpp ;
|
||||
run lsp_convertible_test2.cpp ;
|
||||
|
||||
run make_shared_array_tmp_test.cpp ;
|
||||
|
||||
run lw_thread_test.cpp : : : <threading>multi ;
|
||||
|
||||
compile sp_windows_h_test.cpp ;
|
||||
compile spinlock_windows_h_test.cpp ;
|
||||
compile yield_k_windows_h_test.cpp ;
|
||||
|
||||
lib dll_test : dll_test_lib.cpp : <link>shared:<define>DLL_TEST_DYN_LINK=1 ;
|
||||
explicit dll_test ;
|
||||
|
||||
run dll_test_main.cpp dll_test : : : <link>static : dll_test_static ;
|
||||
run dll_test_main.cpp dll_test : : : <link>shared : dll_test_shared ;
|
||||
|
||||
run make_shared_const_test.cpp ;
|
||||
run make_local_shared_const_test.cpp ;
|
||||
|
||||
lib abi_test_mt : abi_test_lib.cpp : <link>static ;
|
||||
explicit abi_test_mt ;
|
||||
|
||||
obj abi_test_lib_nt : abi_test_lib.cpp : <define>BOOST_DISABLE_THREADS ;
|
||||
explicit abi_test_lib_nt ;
|
||||
|
||||
lib abi_test_nt : abi_test_lib_nt : <link>static ;
|
||||
explicit abi_test_nt ;
|
||||
|
||||
run abi_test_main.cpp abi_test_mt : : : <define>BOOST_DISABLE_THREADS : abi_test_nt_mt ;
|
||||
run abi_test_main.cpp abi_test_nt : : : : abi_test_mt_nt ;
|
||||
|
||||
run abi_test_main.cpp abi_test_mt/<cxxstd>0x : : : <cxxstd>98 : abi_test_03_11 ;
|
||||
run abi_test_main.cpp abi_test_mt/<cxxstd>98 : : : <cxxstd>0x : abi_test_11_03 ;
|
247
test/Jamfile.v2
247
test/Jamfile.v2
@@ -1,247 +0,0 @@
|
||||
# Boost.SmartPtr Library test Jamfile
|
||||
#
|
||||
# Copyright (c) 2003-2017 Peter Dimov
|
||||
# Copyright (c) 2003 Dave Abrahams
|
||||
#
|
||||
# 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)
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
{
|
||||
test-suite "smart_ptr"
|
||||
: [ run smart_ptr_test.cpp ]
|
||||
[ run shared_ptr_basic_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
|
||||
[ run shared_ptr_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
|
||||
[ run weak_ptr_test.cpp ]
|
||||
[ run weak_ptr_move_test.cpp ]
|
||||
[ run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
|
||||
[ run get_deleter_test.cpp ]
|
||||
[ run intrusive_ptr_test.cpp ]
|
||||
[ run intrusive_ptr_move_test.cpp ]
|
||||
[ run intrusive_ref_counter_test.cpp ]
|
||||
[ run atomic_count_test.cpp ]
|
||||
[ run lw_mutex_test.cpp ]
|
||||
[ compile-fail shared_ptr_assign_fail.cpp ]
|
||||
[ compile-fail shared_ptr_delete_fail.cpp ]
|
||||
[ compile-fail shared_ptr_compare_fail.cpp ]
|
||||
[ run shared_ptr_alloc2_test.cpp ]
|
||||
[ run pointer_cast_test.cpp ]
|
||||
[ run cpp11_pointer_cast_test.cpp ]
|
||||
[ compile pointer_to_other_test.cpp ]
|
||||
[ run auto_ptr_rv_test.cpp ]
|
||||
[ run shared_ptr_alias_test.cpp ]
|
||||
[ run shared_ptr_rv_test.cpp ]
|
||||
[ run shared_ptr_rv_pointer_cast_test.cpp ]
|
||||
[ run shared_ptr_move_test.cpp ]
|
||||
[ run shared_ptr_alias_move_test.cpp ]
|
||||
[ run shared_ptr_reinterpret_pointer_cast_test.cpp ]
|
||||
[ compile-fail shared_ptr_pv_fail.cpp ]
|
||||
[ run sp_unary_addr_test.cpp ]
|
||||
[ compile-fail scoped_ptr_eq_fail.cpp ]
|
||||
[ compile-fail scoped_array_eq_fail.cpp ]
|
||||
[ run esft_regtest.cpp ]
|
||||
[ run yield_k_test.cpp ]
|
||||
[ run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ]
|
||||
[ run spinlock_test.cpp ]
|
||||
[ run spinlock_try_test.cpp ]
|
||||
[ run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ]
|
||||
[ run spinlock_pool_test.cpp ]
|
||||
[ run make_shared_test.cpp ]
|
||||
[ run make_shared_move_emulation_test.cpp ]
|
||||
[ run make_shared_perfect_forwarding_test.cpp ]
|
||||
[ run shared_ptr_convertible_test.cpp ]
|
||||
[ run wp_convertible_test.cpp ]
|
||||
[ run ip_convertible_test.cpp ]
|
||||
[ run allocate_shared_test.cpp ]
|
||||
[ run sp_atomic_test.cpp ]
|
||||
[ run esft_void_test.cpp ]
|
||||
[ run esft_second_ptr_test.cpp ]
|
||||
[ run make_shared_esft_test.cpp ]
|
||||
[ run allocate_shared_esft_test.cpp ]
|
||||
[ run sp_recursive_assign_test.cpp ]
|
||||
[ run sp_recursive_assign2_test.cpp ]
|
||||
[ run sp_recursive_assign_rv_test.cpp ]
|
||||
[ run sp_recursive_assign2_rv_test.cpp ]
|
||||
[ compile-fail auto_ptr_lv_fail.cpp ]
|
||||
[ run atomic_count_test2.cpp ]
|
||||
[ run sp_typeinfo_test.cpp ]
|
||||
[ compile make_shared_fp_test.cpp ]
|
||||
[ run sp_hash_test.cpp ]
|
||||
[ run get_deleter_array_test.cpp ]
|
||||
[ run ip_hash_test.cpp ]
|
||||
[ run owner_less_test.cpp ]
|
||||
[ run sp_unique_ptr_test.cpp ]
|
||||
[ run sp_array_test.cpp ]
|
||||
[ compile sp_array_cv_test.cpp ]
|
||||
[ run sp_convertible_test.cpp ]
|
||||
[ run sp_array_n_test.cpp ]
|
||||
[ run sp_array_cast_test.cpp ]
|
||||
[ run sp_zero_compare_test.cpp ]
|
||||
[ run sp_nullptr_test.cpp ]
|
||||
[ run sa_nullptr_test.cpp ]
|
||||
[ run shared_ptr_alloc3_test.cpp ]
|
||||
[ run shared_ptr_alloc11_test.cpp ]
|
||||
[ run shared_ptr_alloc_construct11_test.cpp ]
|
||||
[ run allocate_shared_alloc11_test.cpp ]
|
||||
[ run allocate_shared_construct11_test.cpp ]
|
||||
[ run sp_interlocked_test.cpp ]
|
||||
|
||||
[ compile-fail array_fail_spa_sp_c.cpp ]
|
||||
[ compile-fail array_fail_sp_spa_c.cpp ]
|
||||
[ compile-fail array_fail_spa_spa_c.cpp ]
|
||||
[ compile-fail array_fail_spa_wp_c.cpp ]
|
||||
[ compile-fail array_fail_sp_wpa_c.cpp ]
|
||||
[ compile-fail array_fail_spa_wpa_c.cpp ]
|
||||
[ compile-fail array_fail_wpa_wp_c.cpp ]
|
||||
[ compile-fail array_fail_wp_wpa_c.cpp ]
|
||||
[ compile-fail array_fail_wpa_wpa_c.cpp ]
|
||||
[ compile-fail array_fail_ap_spa_c.cpp ]
|
||||
[ compile-fail array_fail_upa_sp_c.cpp ]
|
||||
[ compile-fail array_fail_up_spa_c.cpp ]
|
||||
|
||||
[ compile-fail array_fail_spa_sp_mc.cpp ]
|
||||
[ compile-fail array_fail_sp_spa_mc.cpp ]
|
||||
[ compile-fail array_fail_spa_spa_mc.cpp ]
|
||||
[ compile-fail array_fail_spa_wp_mc.cpp ]
|
||||
[ compile-fail array_fail_sp_wpa_mc.cpp ]
|
||||
[ compile-fail array_fail_spa_wpa_mc.cpp ]
|
||||
[ compile-fail array_fail_wpa_wp_mc.cpp ]
|
||||
[ compile-fail array_fail_wp_wpa_mc.cpp ]
|
||||
[ compile-fail array_fail_wpa_wpa_mc.cpp ]
|
||||
[ compile-fail array_fail_ap_spa_mc.cpp ]
|
||||
[ compile-fail array_fail_upa_sp_mc.cpp ]
|
||||
[ compile-fail array_fail_up_spa_mc.cpp ]
|
||||
|
||||
[ compile-fail array_fail_spa_sp_a.cpp ]
|
||||
[ compile-fail array_fail_sp_spa_a.cpp ]
|
||||
[ compile-fail array_fail_spa_spa_a.cpp ]
|
||||
[ compile-fail array_fail_spa_wp_a.cpp ]
|
||||
[ compile-fail array_fail_sp_wpa_a.cpp ]
|
||||
[ compile-fail array_fail_spa_wpa_a.cpp ]
|
||||
[ compile-fail array_fail_wpa_wp_a.cpp ]
|
||||
[ compile-fail array_fail_wp_wpa_a.cpp ]
|
||||
[ compile-fail array_fail_wpa_wpa_a.cpp ]
|
||||
[ compile-fail array_fail_ap_spa_a.cpp ]
|
||||
[ compile-fail array_fail_upa_sp_a.cpp ]
|
||||
[ compile-fail array_fail_up_spa_a.cpp ]
|
||||
|
||||
[ compile-fail array_fail_spa_sp_ma.cpp ]
|
||||
[ compile-fail array_fail_sp_spa_ma.cpp ]
|
||||
[ compile-fail array_fail_spa_spa_ma.cpp ]
|
||||
[ compile-fail array_fail_spa_wp_ma.cpp ]
|
||||
[ compile-fail array_fail_sp_wpa_ma.cpp ]
|
||||
[ compile-fail array_fail_spa_wpa_ma.cpp ]
|
||||
[ compile-fail array_fail_wpa_wp_ma.cpp ]
|
||||
[ compile-fail array_fail_wp_wpa_ma.cpp ]
|
||||
[ compile-fail array_fail_wpa_wpa_ma.cpp ]
|
||||
[ compile-fail array_fail_ap_spa_ma.cpp ]
|
||||
[ compile-fail array_fail_upa_sp_ma.cpp ]
|
||||
[ compile-fail array_fail_up_spa_ma.cpp ]
|
||||
|
||||
[ compile-fail array_fail_dereference.cpp ]
|
||||
[ compile-fail array_fail_member_access.cpp ]
|
||||
[ compile-fail array_fail_array_access.cpp ]
|
||||
|
||||
[ run make_shared_array_test.cpp ]
|
||||
[ run make_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ]
|
||||
[ run make_shared_array_throws_test.cpp ]
|
||||
[ run make_shared_array_esft_test.cpp ]
|
||||
[ run make_shared_array_noinit_test.cpp ]
|
||||
[ run make_shared_array_value_test.cpp ]
|
||||
[ run allocate_shared_array_test.cpp ]
|
||||
[ run allocate_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ]
|
||||
[ run allocate_shared_array_throws_test.cpp ]
|
||||
[ run allocate_shared_array_esft_test.cpp ]
|
||||
[ run allocate_shared_array_noinit_test.cpp ]
|
||||
[ run allocate_shared_array_value_test.cpp ]
|
||||
[ run allocate_shared_array_construct_test.cpp ]
|
||||
|
||||
[ run make_unique_test.cpp ]
|
||||
[ run make_unique_args_test.cpp ]
|
||||
[ run make_unique_value_test.cpp ]
|
||||
[ run make_unique_noinit_test.cpp ]
|
||||
[ run make_unique_throws_test.cpp ]
|
||||
[ run make_unique_array_test.cpp ]
|
||||
[ run make_unique_array_noinit_test.cpp ]
|
||||
[ run make_unique_array_throws_test.cpp ]
|
||||
|
||||
[ run shared_from_raw_test.cpp ]
|
||||
[ run shared_from_raw_test2.cpp ]
|
||||
[ run shared_from_raw_test3.cpp ]
|
||||
[ run shared_from_raw_test4.cpp ]
|
||||
[ run shared_from_raw_test5.cpp ]
|
||||
[ run shared_from_raw_test6.cpp ]
|
||||
|
||||
[ run weak_from_raw_test.cpp ]
|
||||
[ run weak_from_raw_test2.cpp ]
|
||||
[ run weak_from_raw_test3.cpp ]
|
||||
[ run weak_from_raw_test4.cpp ]
|
||||
[ run weak_from_raw_test5.cpp ]
|
||||
|
||||
[ compile sp_explicit_inst_test.cpp ]
|
||||
|
||||
[ run weak_from_this_test.cpp ]
|
||||
[ run weak_from_this_test2.cpp ]
|
||||
|
||||
[ run sp_bml_unique_ptr_test.cpp ]
|
||||
|
||||
[ run sp_hash_test2.cpp ]
|
||||
[ run sp_hash_test3.cpp ]
|
||||
|
||||
[ run pointer_cast_test2.cpp ]
|
||||
|
||||
[ compile-fail pointer_cast_st_fail.cpp ]
|
||||
[ compile-fail pointer_cast_st_fail2.cpp ]
|
||||
[ compile-fail pointer_cast_st_fail3.cpp ]
|
||||
|
||||
[ compile-fail pointer_cast_co_fail.cpp ]
|
||||
[ compile-fail pointer_cast_co_fail2.cpp ]
|
||||
[ compile-fail pointer_cast_co_fail3.cpp ]
|
||||
|
||||
[ compile-fail pointer_cast_dy_fail.cpp ]
|
||||
[ compile-fail pointer_cast_dy_fail2.cpp ]
|
||||
[ compile-fail pointer_cast_dy_fail3.cpp ]
|
||||
|
||||
[ run sp_nothrow_test.cpp ]
|
||||
|
||||
[ compile make_shared_msvc_test.cpp ]
|
||||
|
||||
[ compile lwm_win32_cs_test.cpp ]
|
||||
|
||||
[ run atomic_sp_test.cpp ]
|
||||
|
||||
[ run sp_constexpr_test.cpp ]
|
||||
[ run sp_constexpr_test2.cpp ]
|
||||
|
||||
[ run atomic_sp_constexpr_test.cpp ]
|
||||
|
||||
[ run shared_ptr_fn_test.cpp ]
|
||||
|
||||
[ run get_deleter_test2.cpp ]
|
||||
[ run get_deleter_test3.cpp ]
|
||||
[ run get_deleter_array_test2.cpp ]
|
||||
[ run get_deleter_array_test3.cpp ]
|
||||
|
||||
[ run local_sp_test.cpp ]
|
||||
[ run lsp_array_test.cpp ]
|
||||
[ run lsp_array_n_test.cpp ]
|
||||
[ run lsp_array_cv_test.cpp ]
|
||||
[ run lsp_array_cast_test.cpp ]
|
||||
|
||||
[ run get_local_deleter_test.cpp ]
|
||||
[ run get_local_deleter_test2.cpp ]
|
||||
[ run get_local_deleter_test3.cpp ]
|
||||
[ run get_local_deleter_array_test.cpp ]
|
||||
[ run get_local_deleter_array_test2.cpp ]
|
||||
|
||||
[ run make_local_shared_test.cpp ]
|
||||
[ run make_local_shared_esft_test.cpp ]
|
||||
[ run allocate_local_shared_test.cpp ]
|
||||
[ run allocate_local_shared_esft_test.cpp ]
|
||||
|
||||
[ run local_sp_fn_test.cpp ]
|
||||
;
|
||||
}
|
43
test/abi_test_lib.cpp
Normal file
43
test/abi_test_lib.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_DISABLE_THREADS)
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is defined" )
|
||||
#else
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is not defined" )
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_HDR_ATOMIC)
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is defined" )
|
||||
#else
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" )
|
||||
#endif
|
||||
|
||||
void abi_test_1( boost::shared_ptr<void> & p )
|
||||
{
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
p.reset();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 0 );
|
||||
}
|
||||
|
||||
boost::shared_ptr<void> abi_test_2( boost::shared_ptr<void> const & p )
|
||||
{
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
boost::shared_ptr<void> abi_test_3()
|
||||
{
|
||||
return boost::shared_ptr<void>( static_cast<int*>( 0 ) );
|
||||
}
|
82
test/abi_test_main.cpp
Normal file
82
test/abi_test_main.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_DISABLE_THREADS)
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is defined" )
|
||||
#else
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_DISABLE_THREADS is not defined" )
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_CXX11_HDR_ATOMIC)
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is defined" )
|
||||
#else
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_NO_CXX11_HDR_ATOMIC is not defined" )
|
||||
#endif
|
||||
|
||||
void abi_test_1( boost::shared_ptr<void> & p );
|
||||
boost::shared_ptr<void> abi_test_2( boost::shared_ptr<void> const & p );
|
||||
boost::shared_ptr<void> abi_test_3();
|
||||
|
||||
static int deleter_called;
|
||||
|
||||
void deleter( void* )
|
||||
{
|
||||
++deleter_called;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
deleter_called = 0;
|
||||
|
||||
boost::shared_ptr<void> p( static_cast<void*>( 0 ), deleter );
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
abi_test_1( p );
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 0 );
|
||||
BOOST_TEST_EQ( deleter_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
deleter_called = 0;
|
||||
|
||||
boost::shared_ptr<void> p1( static_cast<void*>( 0 ), deleter );
|
||||
|
||||
BOOST_TEST_EQ( p1.use_count(), 1 );
|
||||
|
||||
boost::shared_ptr<void> p2 = abi_test_2( p1 );
|
||||
|
||||
BOOST_TEST_EQ( p1.use_count(), 2 );
|
||||
BOOST_TEST_EQ( p2.use_count(), 2 );
|
||||
|
||||
p1.reset();
|
||||
|
||||
BOOST_TEST_EQ( p2.use_count(), 1 );
|
||||
|
||||
p2.reset();
|
||||
|
||||
BOOST_TEST_EQ( deleter_called, 1 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<void> p = abi_test_3();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 1 );
|
||||
|
||||
p.reset();
|
||||
|
||||
BOOST_TEST_EQ( p.use_count(), 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
165
test/allocate_local_shared_array_construct_test.cpp
Normal file
165
test/allocate_local_shared_array_construct_test.cpp
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
struct allow { };
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void construct(U* ptr) {
|
||||
::new(static_cast<void*>(ptr)) U(allow());
|
||||
}
|
||||
|
||||
template<class U>
|
||||
void destroy(U* ptr) {
|
||||
ptr->~U();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
explicit type(allow) {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::allocate_local_shared<type[]>(creator<type>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::allocate_local_shared<type[3]>(creator<type>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[][2]> result =
|
||||
boost::allocate_local_shared<type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[2][2]> result =
|
||||
boost::allocate_local_shared<type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[]> result =
|
||||
boost::allocate_local_shared<const type[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[3]> result =
|
||||
boost::allocate_local_shared<const type[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[][2]> result =
|
||||
boost::allocate_local_shared<const type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_local_shared<const type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.local_use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
103
test/allocate_local_shared_array_esft_test.cpp
Normal file
103
test/allocate_local_shared_array_esft_test.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
class type
|
||||
: public boost::enable_shared_from_this<type> {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type() {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::allocate_local_shared<type[]>(creator<type>(), 3);
|
||||
try {
|
||||
result[0].shared_from_this();
|
||||
BOOST_ERROR("shared_from_this did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 3);
|
||||
}
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::allocate_local_shared_noinit<type[]>(creator<>(), 3);
|
||||
try {
|
||||
result[0].shared_from_this();
|
||||
BOOST_ERROR("shared_from_this did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 3);
|
||||
}
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
254
test/allocate_local_shared_array_noinit_test.cpp
Normal file
254
test/allocate_local_shared_array_noinit_test.cpp
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type()
|
||||
: value_(0.0) {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
void set(long double value) {
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
long double get() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
long double value_;
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::allocate_local_shared_noinit<int[]>(creator<int>(), 3);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
boost::allocate_local_shared_noinit<int[3]>(creator<int>());
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::allocate_local_shared_noinit<int[][2]>(creator<>(), 2);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::allocate_local_shared_noinit<int[2][2]>(creator<>());
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::allocate_local_shared_noinit<const int[]>(creator<>(), 3);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
boost::allocate_local_shared_noinit<const int[3]>(creator<>());
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::allocate_local_shared_noinit<const int[][2]>(creator<>(), 2);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_local_shared_noinit<const int[2][2]>(creator<>());
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::allocate_local_shared_noinit<type[]>(creator<type>(), 3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::allocate_local_shared_noinit<type[3]>(creator<type>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[][2]> result =
|
||||
boost::allocate_local_shared_noinit<type[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[2][2]> result =
|
||||
boost::allocate_local_shared_noinit<type[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[2][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[]> result =
|
||||
boost::allocate_local_shared_noinit<const type[]>(creator<>(), 3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[3]> result =
|
||||
boost::allocate_local_shared_noinit<const type[3]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[3]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[][2]> result =
|
||||
boost::allocate_local_shared_noinit<const
|
||||
type[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_local_shared_noinit<const type[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
275
test/allocate_local_shared_array_test.cpp
Normal file
275
test/allocate_local_shared_array_test.cpp
Normal file
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type()
|
||||
: value_(0.0) {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
void set(long double value) {
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
long double get() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
long double value_;
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::allocate_local_shared<int[]>(creator<int>(), 3);
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
boost::allocate_local_shared<int[3]>(creator<int>());
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::allocate_local_shared<int[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::allocate_local_shared<int[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::allocate_local_shared<const int[]>(creator<>(), 3);
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
boost::allocate_local_shared<const int[3]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::allocate_local_shared<const int[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_local_shared<const int[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::allocate_local_shared<type[]>(creator<type>(), 3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::allocate_local_shared<type[3]>(creator<type>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[][2]> result =
|
||||
boost::allocate_local_shared<type[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[2][2]> result =
|
||||
boost::allocate_local_shared<type[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[]> result =
|
||||
boost::allocate_local_shared<const type[]>(creator<>(), 3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[3]> result =
|
||||
boost::allocate_local_shared<const type[3]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[][2]> result =
|
||||
boost::allocate_local_shared<const type[][2]>(creator<>(), 2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_local_shared<const type[2][2]>(creator<>());
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
130
test/allocate_local_shared_array_throws_test.cpp
Normal file
130
test/allocate_local_shared_array_throws_test.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type() {
|
||||
if (instances == 5) {
|
||||
throw true;
|
||||
}
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
boost::allocate_local_shared<type[]>(creator<type>(), 6);
|
||||
BOOST_ERROR("allocate_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared<type[][2]>(creator<type>(), 3);
|
||||
BOOST_ERROR("allocate_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared<type[6]>(creator<>());
|
||||
BOOST_ERROR("allocate_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared<type[3][2]>(creator<>());
|
||||
BOOST_ERROR("allocate_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared_noinit<type[]>(creator<>(), 6);
|
||||
BOOST_ERROR("allocate_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared_noinit<type[][2]>(creator<>(), 3);
|
||||
BOOST_ERROR("allocate_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared_noinit<type[6]>(creator<>());
|
||||
BOOST_ERROR("allocate_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_local_shared_noinit<type[3][2]>(creator<>());
|
||||
BOOST_ERROR("allocate_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
92
test/allocate_local_shared_array_value_test.cpp
Normal file
92
test/allocate_local_shared_array_value_test.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::allocate_local_shared<int[]>(creator<int>(), 4, 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[4]> result =
|
||||
boost::allocate_local_shared<int[4]>(creator<int>(), 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::allocate_local_shared<const int[]>(creator<>(), 4, 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[4]> result =
|
||||
boost::allocate_local_shared<const int[4]>(creator<>(), 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
93
test/allocate_local_shared_arrays_test.cpp
Normal file
93
test/allocate_local_shared_arrays_test.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
template<class U>
|
||||
struct rebind {
|
||||
typedef creator<U> other;
|
||||
};
|
||||
|
||||
creator() { }
|
||||
|
||||
template<class U>
|
||||
creator(const creator<U>&) { }
|
||||
|
||||
T* allocate(std::size_t size) {
|
||||
return static_cast<T*>(::operator new(sizeof(T) * size));
|
||||
}
|
||||
|
||||
void deallocate(T* ptr, std::size_t) {
|
||||
::operator delete(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator==(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T, class U>
|
||||
inline bool
|
||||
operator!=(const creator<T>&, const creator<U>&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::allocate_local_shared<int[][2]>(creator<int>(), 2, {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::allocate_local_shared<int[2][2]>(creator<int>(), {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::allocate_local_shared<const int[][2]>(creator<>(), 2, {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_local_shared<const int[2][2]>(creator<>(), {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@@ -5,13 +5,14 @@ Copyright 2012-2015 Glen Joseph Fernandes
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
struct allow { };
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -100,7 +101,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[][2]> result =
|
||||
boost::allocate_shared<type[][2]>(creator<type>(), 2);
|
||||
boost::allocate_shared<type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
@@ -109,7 +110,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[2][2]> result =
|
||||
boost::allocate_shared<type[2][2]>(creator<type>());
|
||||
boost::allocate_shared<type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
@@ -118,7 +119,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[]> result =
|
||||
boost::allocate_shared<const type[]>(creator<type>(), 3);
|
||||
boost::allocate_shared<const type[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
@@ -127,7 +128,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[3]> result =
|
||||
boost::allocate_shared<const type[3]>(creator<type>());
|
||||
boost::allocate_shared<const type[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
@@ -136,7 +137,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[][2]> result =
|
||||
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
|
||||
boost::allocate_shared<const type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
@@ -145,7 +146,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_shared<const type[2][2]>(creator<type>());
|
||||
boost::allocate_shared<const type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(type::instances == 4);
|
||||
|
@@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -82,7 +82,7 @@ int main()
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[]> result =
|
||||
boost::allocate_shared_noinit<type[]>(creator<type>(), 3);
|
||||
boost::allocate_shared_noinit<type[]>(creator<>(), 3);
|
||||
try {
|
||||
result[0].shared_from_this();
|
||||
BOOST_ERROR("shared_from_this did not throw");
|
||||
|
@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -98,7 +98,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[][2]> result =
|
||||
boost::allocate_shared_noinit<int[][2]>(creator<int>(), 2);
|
||||
boost::allocate_shared_noinit<int[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -106,7 +106,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[2][2]> result =
|
||||
boost::allocate_shared_noinit<int[2][2]>(creator<int>());
|
||||
boost::allocate_shared_noinit<int[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -114,7 +114,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[]> result =
|
||||
boost::allocate_shared_noinit<const int[]>(creator<int>(), 3);
|
||||
boost::allocate_shared_noinit<const int[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -122,7 +122,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[3]> result =
|
||||
boost::allocate_shared_noinit<const int[3]>(creator<int>());
|
||||
boost::allocate_shared_noinit<const int[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -130,7 +130,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[][2]> result =
|
||||
boost::allocate_shared_noinit<const int[][2]>(creator<int>(), 2);
|
||||
boost::allocate_shared_noinit<const int[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -138,7 +138,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_shared_noinit<const int[2][2]>(creator<int>());
|
||||
boost::allocate_shared_noinit<const int[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -170,7 +170,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[][2]> result =
|
||||
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 2);
|
||||
boost::allocate_shared_noinit<type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -182,7 +182,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[2][2]> result =
|
||||
boost::allocate_shared_noinit<type[2][2]>(creator<type>());
|
||||
boost::allocate_shared_noinit<type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -194,7 +194,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[]> result =
|
||||
boost::allocate_shared_noinit<const type[]>(creator<type>(), 3);
|
||||
boost::allocate_shared_noinit<const type[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -206,7 +206,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[3]> result =
|
||||
boost::allocate_shared_noinit<const type[3]>(creator<type>());
|
||||
boost::allocate_shared_noinit<const type[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -219,7 +219,7 @@ int main()
|
||||
{
|
||||
boost::shared_ptr<const type[][2]> result =
|
||||
boost::allocate_shared_noinit<const
|
||||
type[][2]>(creator<type>(), 2);
|
||||
type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -231,7 +231,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_shared_noinit<const type[2][2]>(creator<type>());
|
||||
boost::allocate_shared_noinit<const type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
|
@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -104,7 +104,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[][2]> result =
|
||||
boost::allocate_shared<int[][2]>(creator<int>(), 2);
|
||||
boost::allocate_shared<int[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -116,7 +116,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[2][2]> result =
|
||||
boost::allocate_shared<int[2][2]>(creator<int>());
|
||||
boost::allocate_shared<int[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -128,7 +128,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[]> result =
|
||||
boost::allocate_shared<const int[]>(creator<int>(), 3);
|
||||
boost::allocate_shared<const int[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -139,7 +139,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[3]> result =
|
||||
boost::allocate_shared<const int[3]>(creator<int>());
|
||||
boost::allocate_shared<const int[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -150,7 +150,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[][2]> result =
|
||||
boost::allocate_shared<const int[][2]>(creator<int>(), 2);
|
||||
boost::allocate_shared<const int[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -162,7 +162,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_shared<const int[2][2]>(creator<int>());
|
||||
boost::allocate_shared<const int[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -198,7 +198,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[][2]> result =
|
||||
boost::allocate_shared<type[][2]>(creator<type>(), 2);
|
||||
boost::allocate_shared<type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -209,7 +209,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<type[2][2]> result =
|
||||
boost::allocate_shared<type[2][2]>(creator<type>());
|
||||
boost::allocate_shared<type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -220,7 +220,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[]> result =
|
||||
boost::allocate_shared<const type[]>(creator<type>(), 3);
|
||||
boost::allocate_shared<const type[]>(creator<>(), 3);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -231,7 +231,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[3]> result =
|
||||
boost::allocate_shared<const type[3]>(creator<type>());
|
||||
boost::allocate_shared<const type[3]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -242,7 +242,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[][2]> result =
|
||||
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
|
||||
boost::allocate_shared<const type[][2]>(creator<>(), 2);
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
@@ -253,7 +253,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const type[2][2]> result =
|
||||
boost::allocate_shared<const type[2][2]>(creator<type>());
|
||||
boost::allocate_shared<const type[2][2]>(creator<>());
|
||||
BOOST_TEST(result.get() != 0);
|
||||
BOOST_TEST(result.use_count() == 1);
|
||||
BOOST_TEST(boost::alignment::is_aligned(result.get(),
|
||||
|
@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -82,37 +82,37 @@ int main()
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared<type[6]>(creator<type>());
|
||||
boost::allocate_shared<type[6]>(creator<>());
|
||||
BOOST_ERROR("allocate_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared<type[3][2]>(creator<type>());
|
||||
boost::allocate_shared<type[3][2]>(creator<>());
|
||||
BOOST_ERROR("allocate_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared_noinit<type[]>(creator<type>(), 6);
|
||||
boost::allocate_shared_noinit<type[]>(creator<>(), 6);
|
||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 3);
|
||||
boost::allocate_shared_noinit<type[][2]>(creator<>(), 3);
|
||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared_noinit<type[6]>(creator<type>());
|
||||
boost::allocate_shared_noinit<type[6]>(creator<>());
|
||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::allocate_shared_noinit<type[3][2]>(creator<type>());
|
||||
boost::allocate_shared_noinit<type[3][2]>(creator<>());
|
||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
|
@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -65,7 +65,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[]> result =
|
||||
boost::allocate_shared<const int[]>(creator<int>(), 4, 1);
|
||||
boost::allocate_shared<const int[]>(creator<>(), 4, 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
@@ -73,7 +73,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[4]> result =
|
||||
boost::allocate_shared<const int[4]>(creator<int>(), 1);
|
||||
boost::allocate_shared<const int[4]>(creator<>(), 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
|
@@ -5,11 +5,12 @@ Copyright 2012-2015 Glen Joseph Fernandes
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
struct creator {
|
||||
typedef T value_type;
|
||||
|
||||
@@ -66,7 +67,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[][2]> result =
|
||||
boost::allocate_shared<const int[][2]>(creator<int>(), 2, {0, 1});
|
||||
boost::allocate_shared<const int[][2]>(creator<>(), 2, {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
@@ -74,7 +75,7 @@ int main()
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[2][2]> result =
|
||||
boost::allocate_shared<const int[2][2]>(creator<int>(), {0, 1});
|
||||
boost::allocate_shared<const int[2][2]>(creator<>(), {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// atomic_sp_constexpr_test.cpp
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
// Copyright 2017, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -9,32 +9,37 @@
|
||||
//
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
#define HAVE_CONSTEXPR_INIT
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <boost/config/helper_macros.hpp>
|
||||
|
||||
#if defined( BOOST_NO_CXX11_CONSTEXPR )
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_CONSTEXPR")
|
||||
int main() {}
|
||||
|
||||
#if defined(__clang__) && defined( BOOST_NO_CXX14_CONSTEXPR )
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
#elif BOOST_WORKAROUND( BOOST_MSVC, < 1920 )
|
||||
|
||||
// MSVC does not implement static initialization for constexpr
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_MSVC < 1920")
|
||||
int main() {}
|
||||
|
||||
#elif defined(__clang__) && defined( BOOST_NO_CXX14_CONSTEXPR )
|
||||
|
||||
// Clang only implements static initialization for constexpr in C++14 mode
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to __clang__ and BOOST_NO_CXX14_CONSTEXPR")
|
||||
int main() {}
|
||||
|
||||
#elif defined( _LIBCPP_VERSION ) && ( _LIBCPP_VERSION < 6000 )
|
||||
|
||||
#if defined( _LIBCPP_VERSION ) && ( _LIBCPP_VERSION < 5000 )
|
||||
// in libc++, atomic_flag has a non-constexpr constructor from bool
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to _LIBCPP_VERSION " BOOST_STRINGIZE(_LIBCPP_VERSION))
|
||||
int main() {}
|
||||
|
||||
#if !defined( HAVE_CONSTEXPR_INIT ) || defined( BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX )
|
||||
#elif defined( BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX )
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test due to BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
@@ -69,4 +74,4 @@ int main()
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif // #if defined( BOOST_NO_CXX11_CONSEXPR )
|
||||
#endif
|
||||
|
25
test/cmake_subdir_test/CMakeLists.txt
Normal file
25
test/cmake_subdir_test/CMakeLists.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(cmake_subdir_test LANGUAGES CXX)
|
||||
|
||||
add_subdirectory(../.. boostorg/smart_ptr)
|
||||
add_subdirectory(../../../assert boostorg/assert)
|
||||
add_subdirectory(../../../config boostorg/config)
|
||||
add_subdirectory(../../../core boostorg/core)
|
||||
add_subdirectory(../../../move boostorg/move)
|
||||
add_subdirectory(../../../predef boostorg/predef)
|
||||
add_subdirectory(../../../static_assert boostorg/static_assert)
|
||||
add_subdirectory(../../../throw_exception boostorg/throw_exception)
|
||||
add_subdirectory(../../../type_traits boostorg/type_traits)
|
||||
|
||||
add_executable(quick ../quick.cpp)
|
||||
target_link_libraries(quick Boost::smart_ptr Boost::core)
|
||||
|
||||
enable_testing()
|
||||
add_test(quick quick)
|
||||
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
42
test/dll_test_lib.cpp
Normal file
42
test/dll_test_lib.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <memory>
|
||||
|
||||
#if defined(DLL_TEST_DYN_LINK)
|
||||
# define EXPORT BOOST_SYMBOL_EXPORT
|
||||
#else
|
||||
# define EXPORT
|
||||
#endif
|
||||
|
||||
EXPORT boost::shared_ptr<int> dll_test_41()
|
||||
{
|
||||
return boost::shared_ptr<int>( new int( 41 ) );
|
||||
}
|
||||
|
||||
EXPORT boost::shared_ptr<int> dll_test_42()
|
||||
{
|
||||
return boost::make_shared<int>( 42 );
|
||||
}
|
||||
|
||||
EXPORT boost::shared_ptr<int> dll_test_43()
|
||||
{
|
||||
return boost::allocate_shared<int>( std::allocator<int>(), 43 );
|
||||
}
|
||||
|
||||
EXPORT boost::shared_ptr<int[]> dll_test_44()
|
||||
{
|
||||
return boost::make_shared<int[1]>( 44 );
|
||||
}
|
||||
|
||||
EXPORT boost::shared_ptr<int[]> dll_test_45()
|
||||
{
|
||||
return boost::allocate_shared<int[1]>( std::allocator<int>(), 45 );
|
||||
}
|
45
test/dll_test_main.cpp
Normal file
45
test/dll_test_main.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
boost::shared_ptr<int> dll_test_41();
|
||||
boost::shared_ptr<int> dll_test_42();
|
||||
boost::shared_ptr<int> dll_test_43();
|
||||
boost::shared_ptr<int[]> dll_test_44();
|
||||
boost::shared_ptr<int[]> dll_test_45();
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::shared_ptr<int> p = dll_test_41();
|
||||
BOOST_TEST_EQ( *p, 41 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int> p = dll_test_42();
|
||||
BOOST_TEST_EQ( *p, 42 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int> p = dll_test_43();
|
||||
BOOST_TEST_EQ( *p, 43 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int[]> p = dll_test_44();
|
||||
BOOST_TEST_EQ( p[0], 44 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int[]> p = dll_test_45();
|
||||
BOOST_TEST_EQ( p[0], 45 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
108
test/lsp_convertible_test.cpp
Normal file
108
test/lsp_convertible_test.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// lsp_convertible_test.cpp
|
||||
//
|
||||
// Copyright 2012, 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
//
|
||||
|
||||
class X;
|
||||
|
||||
class B
|
||||
{
|
||||
};
|
||||
|
||||
class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
|
||||
|
||||
#define TEST_CV_FALSE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
|
||||
|
||||
using boost::local_shared_ptr;
|
||||
using boost::shared_ptr;
|
||||
using boost::weak_ptr;
|
||||
|
||||
#define TEST_CV_TRUE( T, U ) \
|
||||
TEST_CV_TRUE_( local_shared_ptr, T, local_shared_ptr, U ) \
|
||||
TEST_CV_TRUE_( shared_ptr, T, local_shared_ptr, U )
|
||||
|
||||
#define TEST_CV_FALSE( T, U ) \
|
||||
TEST_CV_FALSE_( local_shared_ptr, T, local_shared_ptr, U ) \
|
||||
TEST_CV_FALSE_( shared_ptr, T, local_shared_ptr, U )
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
TEST_CV_TRUE( X, X )
|
||||
TEST_CV_TRUE( X, void )
|
||||
TEST_CV_FALSE( void, X )
|
||||
TEST_CV_TRUE( D, B )
|
||||
TEST_CV_FALSE( B, D )
|
||||
|
||||
TEST_CV_TRUE( X[], X[] )
|
||||
TEST_CV_FALSE( D[], B[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[3] )
|
||||
TEST_CV_FALSE( X[3], X[4] )
|
||||
TEST_CV_FALSE( D[3], B[3] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[] )
|
||||
TEST_CV_FALSE( X[], X[3] )
|
||||
|
||||
TEST_CV_TRUE( X[], void )
|
||||
TEST_CV_FALSE( void, X[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], void )
|
||||
TEST_CV_FALSE( void, X[3] )
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
108
test/lsp_convertible_test2.cpp
Normal file
108
test/lsp_convertible_test2.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// lsp_convertible_test.cpp
|
||||
//
|
||||
// Copyright 2012, 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
//
|
||||
|
||||
class X;
|
||||
|
||||
class B
|
||||
{
|
||||
};
|
||||
|
||||
class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
|
||||
|
||||
#define TEST_CV_FALSE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
|
||||
|
||||
using boost::local_shared_ptr;
|
||||
using boost::shared_ptr;
|
||||
using boost::weak_ptr;
|
||||
|
||||
#define TEST_CV_TRUE( T, U ) \
|
||||
TEST_CV_TRUE_( local_shared_ptr, T, shared_ptr, U ) \
|
||||
TEST_CV_TRUE_( local_shared_ptr, T, weak_ptr, U )
|
||||
|
||||
#define TEST_CV_FALSE( T, U ) \
|
||||
TEST_CV_FALSE_( local_shared_ptr, T, shared_ptr, U ) \
|
||||
TEST_CV_FALSE_( local_shared_ptr, T, weak_ptr, U )
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
|
||||
|
||||
TEST_CV_TRUE( X, X )
|
||||
TEST_CV_TRUE( X, void )
|
||||
TEST_CV_FALSE( void, X )
|
||||
TEST_CV_TRUE( D, B )
|
||||
TEST_CV_FALSE( B, D )
|
||||
|
||||
TEST_CV_TRUE( X[], X[] )
|
||||
TEST_CV_FALSE( D[], B[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[3] )
|
||||
TEST_CV_FALSE( X[3], X[4] )
|
||||
TEST_CV_FALSE( D[3], B[3] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[] )
|
||||
TEST_CV_FALSE( X[], X[3] )
|
||||
|
||||
TEST_CV_TRUE( X[], void )
|
||||
TEST_CV_FALSE( void, X[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], void )
|
||||
TEST_CV_FALSE( void, X[3] )
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
36
test/lw_thread_test.cpp
Normal file
36
test/lw_thread_test.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
// lw_thread_test.cpp
|
||||
//
|
||||
// Copyright 2018 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
|
||||
#include <boost/detail/lightweight_thread.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/detail/atomic_count.hpp>
|
||||
|
||||
boost::detail::atomic_count count( 0 );
|
||||
|
||||
void f()
|
||||
{
|
||||
++count;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int const N = 4;
|
||||
boost::detail::lw_thread_t th[ N ] = {};
|
||||
|
||||
for( int i = 0; i < N; ++i )
|
||||
{
|
||||
boost::detail::lw_thread_create( th[ i ], f );
|
||||
}
|
||||
|
||||
for( int i = 0; i < N; ++i )
|
||||
{
|
||||
boost::detail::lw_thread_join( th[ i ] );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( count, N );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
66
test/make_local_shared_array_esft_test.cpp
Normal file
66
test/make_local_shared_array_esft_test.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
class type
|
||||
: public boost::enable_shared_from_this<type> {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type() {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::make_local_shared<type[]>(3);
|
||||
try {
|
||||
result[0].shared_from_this();
|
||||
BOOST_ERROR("shared_from_this did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 3);
|
||||
}
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::make_local_shared_noinit<type[3]>();
|
||||
try {
|
||||
result[0].shared_from_this();
|
||||
BOOST_ERROR("shared_from_this did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 3);
|
||||
}
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
216
test/make_local_shared_array_noinit_test.cpp
Normal file
216
test/make_local_shared_array_noinit_test.cpp
Normal file
@@ -0,0 +1,216 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type()
|
||||
: value_(0.0) {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
void set(long double value) {
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
long double get() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
long double value_;
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::make_local_shared_noinit<int[]>(3);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
boost::make_local_shared_noinit<int[3]>();
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::make_local_shared_noinit<int[][2]>(2);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::make_local_shared_noinit<int[2][2]>();
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::make_local_shared_noinit<const int[]>(3);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
boost::make_local_shared_noinit<const int[3]>();
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::make_local_shared_noinit<const int[][2]>(2);
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::make_local_shared_noinit<const int[2][2]>();
|
||||
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));
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::make_local_shared_noinit<type[]>(3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::make_local_shared_noinit<type[3]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[][2]> result =
|
||||
boost::make_local_shared_noinit<type[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[2][2]> result =
|
||||
boost::make_local_shared_noinit<type[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<type[2][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[]> result =
|
||||
boost::make_local_shared_noinit<const type[]>(3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[3]> result =
|
||||
boost::make_local_shared_noinit<const type[3]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<const type[3]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[][2]> result =
|
||||
boost::make_local_shared_noinit<const type[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[2][2]> result =
|
||||
boost::make_local_shared_noinit<const type[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
boost::weak_ptr<const type[2][2]> other = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
238
test/make_local_shared_array_test.cpp
Normal file
238
test/make_local_shared_array_test.cpp
Normal file
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/align/is_aligned.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type()
|
||||
: value_(0.0) {
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
void set(long double value) {
|
||||
value_ = value;
|
||||
}
|
||||
|
||||
long double get() const {
|
||||
return value_;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
|
||||
long double value_;
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::make_local_shared<int[]>(3);
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[3]> result =
|
||||
boost::make_local_shared<int[3]>();
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::make_local_shared<int[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::make_local_shared<int[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::make_local_shared<const int[]>(3);
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[3]> result =
|
||||
boost::make_local_shared<const int[3]>();
|
||||
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));
|
||||
BOOST_TEST(result[0] == 0);
|
||||
BOOST_TEST(result[1] == 0);
|
||||
BOOST_TEST(result[2] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::make_local_shared<const int[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::make_local_shared<const int[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 0);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[]> result =
|
||||
boost::make_local_shared<type[]>(3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[3]> result =
|
||||
boost::make_local_shared<type[3]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = result;
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[][2]> result =
|
||||
boost::make_local_shared<type[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<type[2][2]> result =
|
||||
boost::make_local_shared<type[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[]> result =
|
||||
boost::make_local_shared<const type[]>(3);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[3]> result =
|
||||
boost::make_local_shared<const type[3]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 3);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[][2]> result =
|
||||
boost::make_local_shared<const type[][2]>(2);
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const type[2][2]> result =
|
||||
boost::make_local_shared<const type[2][2]>();
|
||||
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));
|
||||
BOOST_TEST(type::instances == 4);
|
||||
result.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
93
test/make_local_shared_array_throws_test.cpp
Normal file
93
test/make_local_shared_array_throws_test.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned instances;
|
||||
|
||||
type() {
|
||||
if (instances == 5) {
|
||||
throw true;
|
||||
}
|
||||
++instances;
|
||||
}
|
||||
|
||||
~type() {
|
||||
--instances;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
};
|
||||
|
||||
unsigned type::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
try {
|
||||
boost::make_local_shared<type[]>(6);
|
||||
BOOST_ERROR("make_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared<type[][2]>(3);
|
||||
BOOST_ERROR("make_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared<type[6]>();
|
||||
BOOST_ERROR("make_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared<type[3][2]>();
|
||||
BOOST_ERROR("make_local_shared did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared_noinit<type[]>(6);
|
||||
BOOST_ERROR("make_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared_noinit<type[][2]>(3);
|
||||
BOOST_ERROR("make_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared_noinit<type[6]>();
|
||||
BOOST_ERROR("make_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
try {
|
||||
boost::make_local_shared_noinit<type[3][2]>();
|
||||
BOOST_ERROR("make_local_shared_noinit did not throw");
|
||||
} catch (...) {
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
55
test/make_local_shared_array_value_test.cpp
Normal file
55
test/make_local_shared_array_value_test.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[]> result =
|
||||
boost::make_local_shared<int[]>(4, 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[4]> result =
|
||||
boost::make_local_shared<int[4]>(1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[]> result =
|
||||
boost::make_local_shared<const int[]>(4, 1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[4]> result =
|
||||
boost::make_local_shared<const int[4]>(1);
|
||||
BOOST_TEST(result[0] == 1);
|
||||
BOOST_TEST(result[1] == 1);
|
||||
BOOST_TEST(result[2] == 1);
|
||||
BOOST_TEST(result[3] == 1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
56
test/make_local_shared_arrays_test.cpp
Normal file
56
test/make_local_shared_arrays_test.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
Copyright 2017 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
|
||||
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
|
||||
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int[][2]> result =
|
||||
boost::make_local_shared<int[][2]>(2, {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<int[2][2]> result =
|
||||
boost::make_local_shared<int[2][2]>({0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[][2]> result =
|
||||
boost::make_local_shared<const int[][2]>(2, {0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
{
|
||||
boost::local_shared_ptr<const int[2][2]> result =
|
||||
boost::make_local_shared<const int[2][2]>({0, 1});
|
||||
BOOST_TEST(result[0][0] == 0);
|
||||
BOOST_TEST(result[0][1] == 1);
|
||||
BOOST_TEST(result[1][0] == 0);
|
||||
BOOST_TEST(result[1][1] == 1);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
262
test/make_local_shared_const_test.cpp
Normal file
262
test/make_local_shared_const_test.cpp
Normal file
@@ -0,0 +1,262 @@
|
||||
// make_local_shared_const_test.cpp
|
||||
//
|
||||
// Copyright 2007-2009, 2017, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) || defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES )
|
||||
|
||||
int main()
|
||||
{
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_local_shared.hpp>
|
||||
#include <boost/smart_ptr/local_shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
class X
|
||||
{
|
||||
private:
|
||||
|
||||
X( X const & );
|
||||
X & operator=( X const & );
|
||||
|
||||
void * operator new( std::size_t n )
|
||||
{
|
||||
// lack of this definition causes link errors on Comeau C++
|
||||
BOOST_ERROR( "private X::new called" );
|
||||
return ::operator new( n );
|
||||
}
|
||||
|
||||
void operator delete( void * p )
|
||||
{
|
||||
// lack of this definition causes link errors on MSVC
|
||||
BOOST_ERROR( "private X::delete called" );
|
||||
::operator delete( p );
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static int instances;
|
||||
|
||||
int v;
|
||||
|
||||
explicit X( int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0 ): v( a1+a2+a3+a4+a5+a6+a7+a8+a9 )
|
||||
{
|
||||
++instances;
|
||||
}
|
||||
|
||||
~X()
|
||||
{
|
||||
--instances;
|
||||
}
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
template<class T> static long use_count( boost::local_shared_ptr<T> const & p )
|
||||
{
|
||||
return boost::shared_ptr<T>( p ).use_count() - 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr<int const> pi = boost::make_local_shared<int const>();
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<int const> pi = boost::make_local_shared<int const>( 5 );
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 5 );
|
||||
}
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>();
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared_noinit<X const>();
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4, 5 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4, 5, 6 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4, 5, 6, 7 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::local_shared_ptr<X const> pi = boost::make_local_shared<X const>( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
@@ -51,6 +51,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >();
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -73,6 +74,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared_noinit< X >();
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -95,6 +97,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -117,6 +120,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -139,6 +143,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -161,6 +166,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -183,6 +189,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -205,6 +212,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -227,6 +235,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -249,6 +258,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -271,6 +281,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
|
@@ -62,12 +62,20 @@ public:
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
template<class T> static long use_count( boost::local_shared_ptr<T> const & p )
|
||||
{
|
||||
return boost::shared_ptr<T>( p ).use_count() - 1;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::local_shared_ptr< int > pi = boost::make_local_shared< int >();
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 0 );
|
||||
}
|
||||
|
||||
@@ -81,6 +89,9 @@ int main()
|
||||
boost::local_shared_ptr< int > pi = boost::make_local_shared< int >( 5 );
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 5 );
|
||||
}
|
||||
|
||||
@@ -92,6 +103,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
@@ -105,6 +118,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
@@ -118,6 +133,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1 );
|
||||
|
||||
pi.reset();
|
||||
@@ -131,6 +148,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2 );
|
||||
|
||||
pi.reset();
|
||||
@@ -144,6 +163,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3 );
|
||||
|
||||
pi.reset();
|
||||
@@ -157,6 +178,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4 );
|
||||
|
||||
pi.reset();
|
||||
@@ -170,6 +193,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5 );
|
||||
|
||||
pi.reset();
|
||||
@@ -183,6 +208,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
|
||||
|
||||
pi.reset();
|
||||
@@ -196,6 +223,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
|
||||
|
||||
pi.reset();
|
||||
@@ -209,6 +238,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
|
||||
|
||||
pi.reset();
|
||||
@@ -222,6 +253,8 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.local_use_count() == 1 );
|
||||
BOOST_TEST( use_count( pi ) == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
|
||||
|
||||
pi.reset();
|
||||
|
43
test/make_shared_array_tmp_test.cpp
Normal file
43
test/make_shared_array_tmp_test.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
// make_shared_array_tmp_test.cpp
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
struct X
|
||||
{
|
||||
static int destroyed;
|
||||
|
||||
~X()
|
||||
{
|
||||
++destroyed;
|
||||
}
|
||||
};
|
||||
|
||||
int X::destroyed = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
X::destroyed = 0;
|
||||
|
||||
boost::make_shared< X[3] >();
|
||||
|
||||
BOOST_TEST_EQ( X::destroyed, 3 );
|
||||
}
|
||||
|
||||
{
|
||||
X::destroyed = 0;
|
||||
|
||||
boost::make_shared< X[] >( 3 );
|
||||
|
||||
BOOST_TEST_EQ( X::destroyed, 3 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@@ -5,10 +5,11 @@ Copyright 2012-2015 Glen Joseph Fernandes
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/config.hpp>
|
||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||
int main()
|
||||
{
|
||||
{
|
||||
|
232
test/make_shared_const_test.cpp
Normal file
232
test/make_shared_const_test.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
// make_shared_const_test.cpp
|
||||
//
|
||||
// Copyright 2007-2009, 2018 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
class X
|
||||
{
|
||||
private:
|
||||
|
||||
X( X const & );
|
||||
X & operator=( X const & );
|
||||
|
||||
void * operator new( std::size_t n )
|
||||
{
|
||||
// lack of this definition causes link errors on Comeau C++
|
||||
BOOST_ERROR( "private X::new called" );
|
||||
return ::operator new( n );
|
||||
}
|
||||
|
||||
void operator delete( void * p )
|
||||
{
|
||||
// lack of this definition causes link errors on MSVC
|
||||
BOOST_ERROR( "private X::delete called" );
|
||||
::operator delete( p );
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static int instances;
|
||||
|
||||
int v;
|
||||
|
||||
explicit X( int a1 = 0, int a2 = 0, int a3 = 0, int a4 = 0, int a5 = 0, int a6 = 0, int a7 = 0, int a8 = 0, int a9 = 0 ): v( a1+a2+a3+a4+a5+a6+a7+a8+a9 )
|
||||
{
|
||||
++instances;
|
||||
}
|
||||
|
||||
~X()
|
||||
{
|
||||
--instances;
|
||||
}
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::shared_ptr<int const> pi = boost::make_shared<int const>();
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int const> pi = boost::make_shared<int const>( 5 );
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 5 );
|
||||
}
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>();
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared_noinit<X const>();
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4, 5 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4, 5, 6 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4, 5, 6, 7 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X const> pi = boost::make_shared<X const>( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
|
||||
boost::weak_ptr<X const> wp( pi );
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
|
||||
|
||||
pi.reset();
|
||||
|
||||
BOOST_TEST( X::instances == 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@@ -41,6 +41,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >();
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -63,6 +64,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared_noinit< X >();
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -85,6 +87,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -107,6 +110,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -129,6 +133,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -151,6 +156,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -173,6 +179,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -195,6 +202,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -217,6 +225,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -239,6 +248,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
@@ -261,6 +271,7 @@ int main()
|
||||
|
||||
{
|
||||
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
|
||||
BOOST_TEST( px.use_count() == 1 );
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
|
||||
try
|
||||
|
@@ -58,6 +58,8 @@ int main()
|
||||
boost::shared_ptr< int > pi = boost::make_shared< int >();
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 0 );
|
||||
}
|
||||
|
||||
@@ -65,12 +67,15 @@ int main()
|
||||
boost::shared_ptr< int > pi = boost::make_shared_noinit< int >();
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr< int > pi = boost::make_shared< int >( 5 );
|
||||
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
|
||||
BOOST_TEST( *pi == 5 );
|
||||
}
|
||||
|
||||
@@ -82,6 +87,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
@@ -95,6 +101,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 0 );
|
||||
|
||||
pi.reset();
|
||||
@@ -108,6 +115,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1 );
|
||||
|
||||
pi.reset();
|
||||
@@ -121,6 +129,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2 );
|
||||
|
||||
pi.reset();
|
||||
@@ -134,6 +143,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3 );
|
||||
|
||||
pi.reset();
|
||||
@@ -147,6 +157,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4 );
|
||||
|
||||
pi.reset();
|
||||
@@ -160,6 +171,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5 );
|
||||
|
||||
pi.reset();
|
||||
@@ -173,6 +185,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
|
||||
|
||||
pi.reset();
|
||||
@@ -186,6 +199,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
|
||||
|
||||
pi.reset();
|
||||
@@ -199,6 +213,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
|
||||
|
||||
pi.reset();
|
||||
@@ -212,6 +227,7 @@ int main()
|
||||
|
||||
BOOST_TEST( X::instances == 1 );
|
||||
BOOST_TEST( pi.get() != 0 );
|
||||
BOOST_TEST( pi.use_count() == 1 );
|
||||
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
|
||||
|
||||
pi.reset();
|
||||
|
80
test/quick.cpp
Normal file
80
test/quick.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// quick.cpp - a quick (CI) test for Boost.SmartPtr
|
||||
//
|
||||
// Copyright 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
//
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/smart_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
class X
|
||||
{
|
||||
private:
|
||||
|
||||
X( X const & );
|
||||
X & operator=( X const & );
|
||||
|
||||
public:
|
||||
|
||||
static int instances;
|
||||
|
||||
X()
|
||||
{
|
||||
++instances;
|
||||
}
|
||||
|
||||
~X()
|
||||
{
|
||||
--instances;
|
||||
}
|
||||
};
|
||||
|
||||
int X::instances = 0;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::shared_ptr<X> p1( new X );
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
BOOST_TEST_EQ( p1.use_count(), 1 );
|
||||
|
||||
boost::shared_ptr<X> p2( p1 );
|
||||
BOOST_TEST_EQ( p2.use_count(), 2 );
|
||||
|
||||
boost::weak_ptr<X> wp( p1 );
|
||||
BOOST_TEST_EQ( wp.use_count(), 2 );
|
||||
|
||||
p1.reset();
|
||||
BOOST_TEST_EQ( wp.use_count(), 1 );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST_EQ( wp.use_count(), 0 );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<X> p1 = boost::make_shared<X>();
|
||||
BOOST_TEST_EQ( X::instances, 1 );
|
||||
BOOST_TEST_EQ( p1.use_count(), 1 );
|
||||
|
||||
boost::shared_ptr<X> p2( p1 );
|
||||
BOOST_TEST_EQ( p2.use_count(), 2 );
|
||||
|
||||
boost::weak_ptr<X> wp( p1 );
|
||||
BOOST_TEST_EQ( wp.use_count(), 2 );
|
||||
|
||||
p1.reset();
|
||||
BOOST_TEST_EQ( wp.use_count(), 1 );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST_EQ( wp.use_count(), 0 );
|
||||
BOOST_TEST_EQ( X::instances, 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@@ -14,7 +14,7 @@ struct counters {
|
||||
unsigned construct;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
template<class T = void>
|
||||
class creator {
|
||||
public:
|
||||
typedef T value_type;
|
||||
@@ -101,7 +101,7 @@ int main()
|
||||
{
|
||||
counters state = { };
|
||||
boost::shared_ptr<int[]> pointer =
|
||||
boost::allocate_shared<int[]>(creator<int>(&state), 5);
|
||||
boost::allocate_shared<int[]>(creator<>(&state), 5);
|
||||
BOOST_TEST(state.allocate == 1);
|
||||
BOOST_TEST(state.construct == 5);
|
||||
pointer.reset();
|
||||
@@ -111,7 +111,7 @@ int main()
|
||||
{
|
||||
counters state = { };
|
||||
boost::shared_ptr<int[5]> pointer =
|
||||
boost::allocate_shared<int[5]>(creator<int>(&state));
|
||||
boost::allocate_shared<int[5]>(creator<>(&state));
|
||||
BOOST_TEST(state.allocate == 1);
|
||||
BOOST_TEST(state.construct == 5);
|
||||
pointer.reset();
|
||||
|
@@ -764,7 +764,7 @@ void weak_ptr_constructor()
|
||||
boost::shared_ptr<Y> p2(wp);
|
||||
BOOST_ERROR("shared_ptr<Y> p2(wp) failed to throw");
|
||||
}
|
||||
catch(boost::bad_weak_ptr)
|
||||
catch(boost::bad_weak_ptr const&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ void weak_ptr_constructor()
|
||||
boost::shared_ptr<X> p3(wp);
|
||||
BOOST_ERROR("shared_ptr<X> p3(wp) failed to throw");
|
||||
}
|
||||
catch(boost::bad_weak_ptr)
|
||||
catch(boost::bad_weak_ptr const&)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -829,7 +829,7 @@ void weak_ptr_constructor()
|
||||
boost::shared_ptr<Y> p2(wp);
|
||||
BOOST_ERROR("shared_ptr<Y> p2(wp) failed to throw");
|
||||
}
|
||||
catch(boost::bad_weak_ptr)
|
||||
catch(boost::bad_weak_ptr const&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ void weak_ptr_constructor()
|
||||
boost::shared_ptr<X> p3(wp);
|
||||
BOOST_ERROR("shared_ptr<X> p3(wp) failed to throw");
|
||||
}
|
||||
catch(boost::bad_weak_ptr)
|
||||
catch(boost::bad_weak_ptr const&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,8 @@
|
||||
// 20 Jul 99 header name changed to .hpp
|
||||
// 20 Apr 99 additional error tests added.
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 )
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, <= 1910 )
|
||||
#if BOOST_WORKAROUND( BOOST_MSVC, < 1920 )
|
||||
# undef HAVE_CONSTEXPR_INIT
|
||||
#endif
|
||||
|
||||
|
108
test/sp_convertible_test2.cpp
Normal file
108
test/sp_convertible_test2.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <boost/config.hpp>
|
||||
|
||||
// sp_convertible_test2.cpp
|
||||
//
|
||||
// Copyright 2012, 2017 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
//
|
||||
|
||||
class X;
|
||||
|
||||
class B
|
||||
{
|
||||
};
|
||||
|
||||
class D: public B
|
||||
{
|
||||
};
|
||||
|
||||
using boost::is_convertible;
|
||||
|
||||
#define TEST_CV_TRUE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
|
||||
|
||||
#define TEST_CV_FALSE_( S1, T, S2, U ) \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
|
||||
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
|
||||
|
||||
using boost::shared_ptr;
|
||||
using boost::weak_ptr;
|
||||
|
||||
#define TEST_CV_TRUE( T, U ) \
|
||||
TEST_CV_TRUE_( shared_ptr, T, shared_ptr, U ) \
|
||||
TEST_CV_TRUE_( shared_ptr, T, weak_ptr, U ) \
|
||||
TEST_CV_TRUE_( weak_ptr, T, weak_ptr, U )
|
||||
|
||||
#define TEST_CV_FALSE( T, U ) \
|
||||
TEST_CV_FALSE_( shared_ptr, T, shared_ptr, U ) \
|
||||
TEST_CV_FALSE_( shared_ptr, T, weak_ptr, U ) \
|
||||
TEST_CV_FALSE_( weak_ptr, T, weak_ptr, U )
|
||||
|
||||
int main()
|
||||
{
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
TEST_CV_TRUE( X, X )
|
||||
TEST_CV_TRUE( X, void )
|
||||
TEST_CV_FALSE( void, X )
|
||||
TEST_CV_TRUE( D, B )
|
||||
TEST_CV_FALSE( B, D )
|
||||
|
||||
TEST_CV_TRUE( X[], X[] )
|
||||
TEST_CV_FALSE( D[], B[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[3] )
|
||||
TEST_CV_FALSE( X[3], X[4] )
|
||||
TEST_CV_FALSE( D[3], B[3] )
|
||||
|
||||
TEST_CV_TRUE( X[3], X[] )
|
||||
TEST_CV_FALSE( X[], X[3] )
|
||||
|
||||
TEST_CV_TRUE( X[], void )
|
||||
TEST_CV_FALSE( void, X[] )
|
||||
|
||||
TEST_CV_TRUE( X[3], void )
|
||||
TEST_CV_FALSE( void, X[3] )
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user