forked from boostorg/smart_ptr
Compare commits
30 Commits
boost-1.68
...
feature/cm
Author | SHA1 | Date | |
---|---|---|---|
|
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 |
68
.travis.yml
68
.travis.yml
@@ -1,4 +1,4 @@
|
||||
# Copyright 2016, 2017, 2018 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)
|
||||
|
||||
@@ -24,7 +24,7 @@ matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: g++
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11 VARIANT=debug,release
|
||||
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: g++-4.4
|
||||
@@ -97,7 +97,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 VARIANT=release
|
||||
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -105,6 +105,16 @@ matrix:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-8
|
||||
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- g++-8
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
|
||||
- os: linux
|
||||
compiler: g++-7
|
||||
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17 UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
|
||||
@@ -117,7 +127,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11 VARIANT=debug,release
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11
|
||||
|
||||
- os: linux
|
||||
compiler: /usr/bin/clang++
|
||||
@@ -206,7 +216,7 @@ matrix:
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z VARIANT=release
|
||||
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -216,19 +226,42 @@ matrix:
|
||||
- llvm-toolchain-trusty-5.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-5.0
|
||||
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
|
||||
compiler: clang++-6.0
|
||||
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-5.0
|
||||
- clang-6.0
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-trusty-5.0
|
||||
- llvm-toolchain-trusty-6.0
|
||||
|
||||
- os: linux
|
||||
compiler: clang++-7
|
||||
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- clang-7
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
- llvm-toolchain-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 VARIANT=release
|
||||
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
@@ -246,6 +279,15 @@ matrix:
|
||||
compiler: clang++
|
||||
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,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
|
||||
- cd ..
|
||||
@@ -265,7 +307,9 @@ install:
|
||||
- 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
|
||||
@@ -273,7 +317,7 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
|
||||
- ./b2 -j3 libs/smart_ptr/test toolset=$TOOLSET cxxstd=$CXXSTD ${VARIANT:+variant=$VARIANT} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
|
||||
- ./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
|
||||
)
|
@@ -44,7 +44,7 @@ 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
|
||||
@@ -60,8 +60,10 @@ install:
|
||||
- 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
|
||||
- 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
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
@@ -158,6 +164,18 @@ template<class Y> intrusive_ptr(intrusive_ptr<Y> const & r);
|
||||
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]
|
||||
|
@@ -30,7 +30,7 @@ struct lsp_if_size_array<T[N]> {
|
||||
typedef boost::local_shared_ptr<T[N]> type;
|
||||
};
|
||||
|
||||
class lsp_array_base
|
||||
class BOOST_SYMBOL_VISIBLE lsp_array_base
|
||||
: public local_counted_base {
|
||||
public:
|
||||
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2012-2017 Glen Joseph Fernandes
|
||||
Copyright 2012-2018 Glen Joseph Fernandes
|
||||
(glenjofe@gmail.com)
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
@@ -154,33 +154,58 @@ sp_array_destroy(A&, T*, std::size_t) BOOST_SP_NOEXCEPT { }
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<!E &&
|
||||
!boost::has_trivial_destructor<T>::value>::type
|
||||
sp_array_destroy(A&, T* start, std::size_t size)
|
||||
sp_array_destroy(A&, T* ptr, std::size_t size)
|
||||
{
|
||||
while (size > 0) {
|
||||
start[--size].~T();
|
||||
ptr[--size].~T();
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<E>::type
|
||||
sp_array_destroy(A& allocator, T* start, std::size_t size)
|
||||
sp_array_destroy(A& allocator, T* ptr, std::size_t size)
|
||||
{
|
||||
while (size > 0) {
|
||||
std::allocator_traits<A>::destroy(allocator, start + --size);
|
||||
std::allocator_traits<A>::destroy(allocator, ptr + --size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<bool E, class A, class T>
|
||||
class sp_destroyer {
|
||||
public:
|
||||
sp_destroyer(A& allocator, T* ptr) BOOST_SP_NOEXCEPT
|
||||
: allocator_(allocator),
|
||||
ptr_(ptr),
|
||||
size_(0) { }
|
||||
|
||||
~sp_destroyer() {
|
||||
sp_array_destroy<E>(allocator_, ptr_, size_);
|
||||
}
|
||||
|
||||
std::size_t& size() BOOST_SP_NOEXCEPT {
|
||||
return size_;
|
||||
}
|
||||
|
||||
private:
|
||||
sp_destroyer(const sp_destroyer&);
|
||||
sp_destroyer& operator=(const sp_destroyer&);
|
||||
|
||||
A& allocator_;
|
||||
T* ptr_;
|
||||
std::size_t size_;
|
||||
};
|
||||
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<!E &&
|
||||
boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value>::type
|
||||
sp_array_construct(A&, T* start, std::size_t size)
|
||||
sp_array_construct(A&, T* ptr, std::size_t size)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
start[i] = T();
|
||||
ptr[i] = T();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,30 +214,11 @@ inline typename sp_enable<!E &&
|
||||
boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value>::type
|
||||
sp_array_construct(A&, T* start, std::size_t size, const T* list,
|
||||
sp_array_construct(A&, T* ptr, std::size_t size, const T* list,
|
||||
std::size_t count)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
start[i] = list[i % count];
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<!E &&
|
||||
!(boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value)>::type
|
||||
sp_array_construct(A& none, T* start, std::size_t size)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
for (; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T();
|
||||
}
|
||||
} catch (...) {
|
||||
sp_array_destroy<E>(none, start, i);
|
||||
throw;
|
||||
ptr[i] = list[i % count];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,30 +227,13 @@ inline typename sp_enable<!E &&
|
||||
!(boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value)>::type
|
||||
sp_array_construct(A& none, T* start, std::size_t size, const T* list,
|
||||
std::size_t count)
|
||||
sp_array_construct(A& none, T* ptr, std::size_t size)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
for (; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T(list[i % count]);
|
||||
}
|
||||
} catch (...) {
|
||||
sp_array_destroy<E>(none, start, i);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#else
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<!E &&
|
||||
!(boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value)>::type
|
||||
sp_array_construct(A&, T* start, std::size_t size)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T();
|
||||
sp_destroyer<E, A, T> hold(none, ptr);
|
||||
for (std::size_t& i = hold.size(); i < size; ++i) {
|
||||
::new(static_cast<void*>(ptr + i)) T();
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<bool E, class A, class T>
|
||||
@@ -252,100 +241,56 @@ inline typename sp_enable<!E &&
|
||||
!(boost::has_trivial_constructor<T>::value &&
|
||||
boost::has_trivial_assign<T>::value &&
|
||||
boost::has_trivial_destructor<T>::value)>::type
|
||||
sp_array_construct(A&, T* start, std::size_t size, const T* list,
|
||||
sp_array_construct(A& none, T* ptr, std::size_t size, const T* list,
|
||||
std::size_t count)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T(list[i % count]);
|
||||
sp_destroyer<E, A, T> hold(none, ptr);
|
||||
for (std::size_t& i = hold.size(); i < size; ++i) {
|
||||
::new(static_cast<void*>(ptr + i)) T(list[i % count]);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<E>::type
|
||||
sp_array_construct(A& allocator, T* start, std::size_t size)
|
||||
sp_array_construct(A& allocator, T* ptr, std::size_t size)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
for (i = 0; i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, start + i);
|
||||
}
|
||||
} catch (...) {
|
||||
sp_array_destroy<E>(allocator, start, i);
|
||||
throw;
|
||||
sp_destroyer<E, A, T> hold(allocator, ptr);
|
||||
for (std::size_t& i = hold.size(); i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, ptr + i);
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<E>::type
|
||||
sp_array_construct(A& allocator, T* start, std::size_t size, const T* list,
|
||||
sp_array_construct(A& allocator, T* ptr, std::size_t size, const T* list,
|
||||
std::size_t count)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
for (i = 0; i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, start + i,
|
||||
sp_destroyer<E, A, T> hold(allocator, ptr);
|
||||
for (std::size_t& i = hold.size(); i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, ptr + i,
|
||||
list[i % count]);
|
||||
}
|
||||
} catch (...) {
|
||||
sp_array_destroy<E>(allocator, start, i);
|
||||
throw;
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#else
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<E>::type
|
||||
sp_array_construct(A& allocator, T* start, std::size_t size)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, start + i);
|
||||
}
|
||||
}
|
||||
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<E>::type
|
||||
sp_array_construct(A& allocator, T* start, std::size_t size, const T* list,
|
||||
std::size_t count)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
std::allocator_traits<A>::construct(allocator, start + i,
|
||||
list[i % count]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template<class A, class T>
|
||||
inline typename sp_enable<boost::has_trivial_constructor<T>::value>::type
|
||||
sp_array_default(A&, T*, std::size_t) BOOST_SP_NOEXCEPT { }
|
||||
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
template<class A, class T>
|
||||
inline typename sp_enable<!boost::has_trivial_constructor<T>::value>::type
|
||||
sp_array_default(A& none, T* start, std::size_t size)
|
||||
sp_array_default(A& none, T* ptr, std::size_t size)
|
||||
{
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
for (; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T;
|
||||
}
|
||||
} catch (...) {
|
||||
sp_array_destroy<false>(none, start, i);
|
||||
throw;
|
||||
sp_destroyer<false, A, T> hold(none, ptr);
|
||||
for (std::size_t& i = hold.size(); i < size; ++i) {
|
||||
::new(static_cast<void*>(ptr + i)) T;
|
||||
}
|
||||
hold.size() = 0;
|
||||
}
|
||||
#else
|
||||
template<bool E, class A, class T>
|
||||
inline typename sp_enable<!boost::has_trivial_constructor<T>::value>::type
|
||||
sp_array_default(A&, T* start, std::size_t size)
|
||||
{
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
::new(static_cast<void*>(start + i)) T;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template<class A>
|
||||
class sp_array_state {
|
||||
@@ -479,7 +424,7 @@ private:
|
||||
struct sp_default { };
|
||||
|
||||
template<class T, bool E = sp_use_construct<T>::value>
|
||||
class sp_array_base
|
||||
class BOOST_SYMBOL_VISIBLE sp_array_base
|
||||
: public sp_counted_base {
|
||||
typedef typename T::type allocator;
|
||||
|
||||
|
@@ -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";
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ namespace boost
|
||||
namespace detail
|
||||
{
|
||||
|
||||
class local_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE local_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class local_counted_impl: public local_counted_base
|
||||
class BOOST_SYMBOL_VISIBLE local_counted_impl: public local_counted_base
|
||||
{
|
||||
private:
|
||||
|
||||
@@ -124,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:
|
||||
|
||||
|
@@ -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,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
@@ -63,7 +64,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:
|
||||
|
||||
|
@@ -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
|
||||
{
|
||||
@@ -108,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,8 @@
|
||||
//
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -26,15 +28,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)
|
||||
|
||||
public:
|
||||
|
||||
|
@@ -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,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/detail/sp_typeinfo.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -57,7 +58,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:
|
||||
|
||||
|
@@ -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:
|
||||
|
||||
|
@@ -64,7 +64,7 @@ template<class D> D * get_local_deleter( local_sp_deleter<D> * p );
|
||||
|
||||
//
|
||||
|
||||
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:
|
||||
|
||||
@@ -143,7 +143,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:
|
||||
|
||||
@@ -216,7 +216,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:
|
||||
|
||||
|
@@ -42,6 +42,11 @@
|
||||
|
||||
# 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 )
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
@@ -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
|
||||
|
38
test/Jamfile
38
test/Jamfile
@@ -7,19 +7,25 @@
|
||||
# accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
# bring in rules for testing
|
||||
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 : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
|
||||
run shared_ptr_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
|
||||
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 : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
|
||||
run shared_from_this_test.cpp ;
|
||||
run get_deleter_test.cpp ;
|
||||
run intrusive_ptr_test.cpp ;
|
||||
run intrusive_ptr_move_test.cpp ;
|
||||
@@ -276,3 +282,27 @@ 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 ;
|
||||
|
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();
|
||||
}
|
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();
|
||||
}
|
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
|
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();
|
||||
}
|
@@ -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&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user