mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-10-04 19:51:02 +02:00
Compare commits
33 Commits
boost-1.60
...
boost-1.62
Author | SHA1 | Date | |
---|---|---|---|
|
f3279d24b4 | ||
|
c87b6e8af8 | ||
|
aaded4f85c | ||
|
eb1a002e34 | ||
|
3304a56101 | ||
|
181f38682f | ||
|
5b1a8412c3 | ||
|
e52905cf3c | ||
|
b7f99ceba6 | ||
|
a7ade6f062 | ||
|
097d2e9bf9 | ||
|
d44a78d671 | ||
|
582eb63cb3 | ||
|
181b449a57 | ||
|
da8de3e95b | ||
|
6c27833099 | ||
|
83e6e00456 | ||
|
522f6c1869 | ||
|
cd8de9d4a6 | ||
|
e26542272d | ||
|
e13beef5df | ||
|
8298952a12 | ||
|
821925c536 | ||
|
427124543b | ||
|
46f00ea993 | ||
|
4473bf8ec2 | ||
|
7a7ac4512e | ||
|
38b6334e36 | ||
|
7af503d3bb | ||
|
05d5a4e9a0 | ||
|
970a179ac2 | ||
|
fd543d3292 | ||
|
334654de06 |
48
.travis.yml
Normal file
48
.travis.yml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Copyright 2016 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)
|
||||||
|
|
||||||
|
language: cpp
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
os:
|
||||||
|
- linux
|
||||||
|
- osx
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
|
||||||
|
install:
|
||||||
|
- git clone -b $TRAVIS_BRANCH https://github.com/boostorg/boost.git boost
|
||||||
|
- cd boost
|
||||||
|
- git submodule init libs/align
|
||||||
|
- git submodule init libs/assert
|
||||||
|
- git submodule init libs/atomic
|
||||||
|
- git submodule init libs/config
|
||||||
|
- 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/smart_ptr
|
||||||
|
- git submodule init libs/static_assert
|
||||||
|
- git submodule init libs/throw_exception
|
||||||
|
- git submodule init libs/type_traits
|
||||||
|
- git submodule init tools/build
|
||||||
|
- git submodule init tools/inspect
|
||||||
|
- git submodule update
|
||||||
|
- cd libs/smart_ptr
|
||||||
|
- git checkout -q $TRAVIS_COMMIT
|
||||||
|
- cd ../..
|
||||||
|
- ./bootstrap.sh
|
||||||
|
- ./b2 headers
|
||||||
|
|
||||||
|
script:
|
||||||
|
- TOOLSET=gcc,clang
|
||||||
|
- if [ $TRAVIS_OS_NAME == osx ]; then TOOLSET=clang; fi
|
||||||
|
- ./b2 libs/smart_ptr/test toolset=$TOOLSET
|
6
README.md
Normal file
6
README.md
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Boost.SmartPtr
|
||||||
|
|
||||||
|
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)
|
44
appveyor.yml
Normal file
44
appveyor.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Copyright 2016 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)
|
||||||
|
|
||||||
|
version: 1.0.{build}-{branch}
|
||||||
|
|
||||||
|
shallow_clone: true
|
||||||
|
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
|
||||||
|
install:
|
||||||
|
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost
|
||||||
|
- cd boost
|
||||||
|
- git submodule init libs/align
|
||||||
|
- git submodule init libs/assert
|
||||||
|
- git submodule init libs/atomic
|
||||||
|
- git submodule init libs/config
|
||||||
|
- 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/smart_ptr
|
||||||
|
- git submodule init libs/static_assert
|
||||||
|
- git submodule init libs/throw_exception
|
||||||
|
- git submodule init libs/type_traits
|
||||||
|
- git submodule init tools/build
|
||||||
|
- git submodule init tools/inspect
|
||||||
|
- git submodule update
|
||||||
|
- cd libs\smart_ptr
|
||||||
|
- git checkout -q %APPVEYOR_REPO_COMMIT%
|
||||||
|
- cd ..\..
|
||||||
|
- bootstrap
|
||||||
|
- b2 headers
|
||||||
|
|
||||||
|
build: off
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- b2 libs/smart_ptr/test toolset=msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0
|
@@ -1,11 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#ifndef BOOST_MAKE_UNIQUE_HPP_INCLUDED
|
#ifndef BOOST_MAKE_UNIQUE_HPP_INCLUDED
|
||||||
#define BOOST_MAKE_UNIQUE_HPP_INCLUDED
|
#define BOOST_MAKE_UNIQUE_HPP_INCLUDED
|
||||||
|
|
||||||
|
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
|
||||||
* glenfe at live dot com
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef BOOST_SMART_PTR_DETAIL_UP_IF_ARRAY_HPP
|
|
||||||
#define BOOST_SMART_PTR_DETAIL_UP_IF_ARRAY_HPP
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace detail {
|
|
||||||
template<class T>
|
|
||||||
struct up_if_array;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct up_if_array<T[]> {
|
|
||||||
typedef std::unique_ptr<T[]> type;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
|
||||||
* glenfe at live dot com
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef BOOST_SMART_PTR_DETAIL_UP_IF_NOT_ARRAY_HPP
|
|
||||||
#define BOOST_SMART_PTR_DETAIL_UP_IF_NOT_ARRAY_HPP
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
namespace detail {
|
|
||||||
template<class T>
|
|
||||||
struct up_if_not_array {
|
|
||||||
typedef std::unique_ptr<T> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct up_if_not_array<T[]> {
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, std::size_t N>
|
|
||||||
struct up_if_not_array<T[N]> {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -104,7 +104,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: invoked automatically by shared_ptr; do not call
|
// Note: invoked automatically by shared_ptr; do not call
|
||||||
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> * ppx, Y * py ) const
|
template<class X, class Y> void _internal_accept_owner( shared_ptr<X> * ppx, Y * ) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( ppx != 0 );
|
BOOST_ASSERT( ppx != 0 );
|
||||||
|
|
||||||
|
@@ -59,7 +59,7 @@ public:
|
|||||||
|
|
||||||
typedef T element_type;
|
typedef T element_type;
|
||||||
|
|
||||||
intrusive_ptr() BOOST_NOEXCEPT : px( 0 )
|
BOOST_CONSTEXPR intrusive_ptr() BOOST_NOEXCEPT : px( 0 )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,6 +122,30 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class U> friend class intrusive_ptr;
|
||||||
|
|
||||||
|
template<class U>
|
||||||
|
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||||
|
|
||||||
|
intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
intrusive_ptr(intrusive_ptr<U> && rhs)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
: px( rhs.px )
|
||||||
|
{
|
||||||
|
rhs.px = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U>
|
||||||
|
intrusive_ptr & operator=(intrusive_ptr<U> && rhs) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
intrusive_ptr & operator=(intrusive_ptr const & rhs)
|
intrusive_ptr & operator=(intrusive_ptr const & rhs)
|
||||||
|
@@ -83,7 +83,7 @@ struct thread_safe_counter
|
|||||||
|
|
||||||
static unsigned int decrement(boost::detail::atomic_count& counter) BOOST_NOEXCEPT
|
static unsigned int decrement(boost::detail::atomic_count& counter) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return --counter;
|
return static_cast< unsigned int >(--counter);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1,15 +1,105 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
|
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
|
||||||
#define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
|
#define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
|
||||||
|
|
||||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.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 make_unique()
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(new T());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||||
|
template<class T, class... Args>
|
||||||
|
inline typename detail::up_if_object<T>::type
|
||||||
|
make_unique(Args&&... args)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename detail::up_if_object<T>::type
|
||||||
|
make_unique(typename detail::up_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 make_unique_noinit()
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(new T);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename detail::up_if_array<T>::type make_unique(std::size_t n)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(new
|
||||||
|
typename detail::up_element<T>::type[n]());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline typename detail::up_if_array<T>::type
|
||||||
|
make_unique_noinit(std::size_t n)
|
||||||
|
{
|
||||||
|
return std::unique_ptr<T>(new
|
||||||
|
typename detail::up_element<T>::type[n]);
|
||||||
|
}
|
||||||
|
} /* boost */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
|
||||||
* glenfe at live dot com
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_ARRAY_HPP
|
|
||||||
#define BOOST_SMART_PTR_MAKE_UNIQUE_ARRAY_HPP
|
|
||||||
|
|
||||||
#include <boost/smart_ptr/detail/up_if_array.hpp>
|
|
||||||
#include <boost/smart_ptr/detail/array_traits.hpp>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
template<class T>
|
|
||||||
inline typename boost::detail::up_if_array<T>::type
|
|
||||||
make_unique(std::size_t size) {
|
|
||||||
typedef typename boost::detail::array_inner<T>::type U;
|
|
||||||
return std::unique_ptr<T>(new U[size]());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline typename boost::detail::up_if_array<T>::type
|
|
||||||
make_unique_noinit(std::size_t size) {
|
|
||||||
typedef typename boost::detail::array_inner<T>::type U;
|
|
||||||
return std::unique_ptr<T>(new U[size]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
|
||||||
* glenfe at live dot com
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef BOOST_SMART_PTR_MAKE_UNIQUE_OBJECT_HPP
|
|
||||||
#define BOOST_SMART_PTR_MAKE_UNIQUE_OBJECT_HPP
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
|
||||||
#include <boost/smart_ptr/detail/up_if_not_array.hpp>
|
|
||||||
#include <boost/type_traits/add_rvalue_reference.hpp>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace boost {
|
|
||||||
template<class T>
|
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
|
||||||
make_unique() {
|
|
||||||
return std::unique_ptr<T>(new T());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
|
||||||
template<class T, class... Args>
|
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
|
||||||
make_unique(Args&&... args) {
|
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
|
||||||
make_unique(typename add_rvalue_reference<T>::type value) {
|
|
||||||
return std::unique_ptr<T>(new T(std::move(value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
|
||||||
make_unique_noinit() {
|
|
||||||
return std::unique_ptr<T>(new T);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -642,6 +642,14 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// aliasing move
|
||||||
|
template<class Y>
|
||||||
|
shared_ptr( shared_ptr<Y> && r, element_type * p ) BOOST_NOEXCEPT : px( p ), pn()
|
||||||
|
{
|
||||||
|
pn.swap( r.pn );
|
||||||
|
r.px = 0;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
#if !defined( BOOST_NO_CXX11_NULLPTR )
|
||||||
@@ -679,7 +687,16 @@ public:
|
|||||||
{
|
{
|
||||||
this_type( r, p ).swap( *this );
|
this_type( r, p ).swap( *this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||||
|
|
||||||
|
template<class Y> void reset( shared_ptr<Y> && r, element_type * p )
|
||||||
|
{
|
||||||
|
this_type( static_cast< shared_ptr<Y> && >( r ), p ).swap( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
|
// never throws (but has a BOOST_ASSERT in it, so not marked with BOOST_NOEXCEPT)
|
||||||
typename boost::detail::sp_dereference< T >::type operator* () const
|
typename boost::detail::sp_dereference< T >::type operator* () const
|
||||||
{
|
{
|
||||||
@@ -1065,7 +1082,7 @@ template< class T > struct hash;
|
|||||||
|
|
||||||
template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT
|
template< class T > std::size_t hash_value( boost::shared_ptr<T> const & p ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return boost::hash< T* >()( p.get() );
|
return boost::hash< typename boost::shared_ptr<T>::element_type* >()( p.get() );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@@ -139,6 +139,8 @@ void bad()
|
|||||||
|
|
||||||
template<class Y> <a href="#aliasing_constructor" >shared_ptr</a>(shared_ptr<Y> const & r, element_type * p); // never throws
|
template<class Y> <a href="#aliasing_constructor" >shared_ptr</a>(shared_ptr<Y> const & r, element_type * p); // never throws
|
||||||
|
|
||||||
|
template<class Y> <a href="#aliasing_move_constructor" >shared_ptr</a>(shared_ptr<Y> && r, element_type * p); // never throws
|
||||||
|
|
||||||
template<class Y> explicit <a href="#weak_ptr_constructor" >shared_ptr</a>(<a href="weak_ptr.htm" >weak_ptr</a><Y> const & r);
|
template<class Y> explicit <a href="#weak_ptr_constructor" >shared_ptr</a>(<a href="weak_ptr.htm" >weak_ptr</a><Y> const & r);
|
||||||
|
|
||||||
template<class Y> explicit <a href="#auto_ptr_constructor" >shared_ptr</a>(std::auto_ptr<Y> & r);
|
template<class Y> explicit <a href="#auto_ptr_constructor" >shared_ptr</a>(std::auto_ptr<Y> & r);
|
||||||
@@ -352,6 +354,16 @@ template<class Y> shared_ptr(shared_ptr<Y> && r); // never t
|
|||||||
<p><b>Postconditions:</b> <code>get() == p && use_count() == r.use_count()</code>.</p>
|
<p><b>Postconditions:</b> <code>get() == p && use_count() == r.use_count()</code>.</p>
|
||||||
<p><b>Throws:</b> nothing.</p>
|
<p><b>Throws:</b> nothing.</p>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
<h3 id="aliasing_move_constructor">aliasing move constructor</h3>
|
||||||
|
<pre>template<class Y> shared_ptr(shared_ptr<Y> && r, element_type * p); // never throws</pre>
|
||||||
|
<blockquote>
|
||||||
|
<p>
|
||||||
|
<b>Effects:</b> Move-constructs a <code>shared_ptr</code> from <code>r</code>, while
|
||||||
|
storing <code>p</code> instead.
|
||||||
|
</p>
|
||||||
|
<p><b>Postconditions:</b> <code>get() == p</code> and <code>use_count()</code> equals the old count of <code>r</code>. <code>r</code> is <em>empty</em> and <code>r.get() == 0</code>.</p>
|
||||||
|
<p><b>Throws:</b> nothing.</p>
|
||||||
|
</blockquote>
|
||||||
<h3 id="weak_ptr_constructor">weak_ptr constructor</h3>
|
<h3 id="weak_ptr_constructor">weak_ptr constructor</h3>
|
||||||
<pre>template<class Y> explicit shared_ptr(<a href="weak_ptr.htm" >weak_ptr</a><Y> const & r);</pre>
|
<pre>template<class Y> explicit shared_ptr(<a href="weak_ptr.htm" >weak_ptr</a><Y> const & r);</pre>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
|
@@ -34,6 +34,7 @@ import testing ;
|
|||||||
[ run shared_ptr_alias_test.cpp ]
|
[ run shared_ptr_alias_test.cpp ]
|
||||||
[ run shared_ptr_rv_test.cpp ]
|
[ run shared_ptr_rv_test.cpp ]
|
||||||
[ run shared_ptr_move_test.cpp ]
|
[ run shared_ptr_move_test.cpp ]
|
||||||
|
[ run shared_ptr_alias_move_test.cpp ]
|
||||||
[ compile-fail shared_ptr_pv_fail.cpp ]
|
[ compile-fail shared_ptr_pv_fail.cpp ]
|
||||||
[ run sp_unary_addr_test.cpp ]
|
[ run sp_unary_addr_test.cpp ]
|
||||||
[ compile-fail scoped_ptr_eq_fail.cpp ]
|
[ compile-fail scoped_ptr_eq_fail.cpp ]
|
||||||
@@ -181,5 +182,8 @@ import testing ;
|
|||||||
[ run weak_from_this_test2.cpp ]
|
[ run weak_from_this_test2.cpp ]
|
||||||
|
|
||||||
[ run sp_bml_unique_ptr_test.cpp ]
|
[ run sp_bml_unique_ptr_test.cpp ]
|
||||||
|
|
||||||
|
[ run sp_hash_test2.cpp ]
|
||||||
|
[ run sp_hash_test3.cpp ]
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@@ -1,43 +1,38 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
|
||||||
|
struct tag { };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class creator {
|
class creator {
|
||||||
public:
|
public:
|
||||||
typedef T value_type;
|
typedef T value_type;
|
||||||
|
|
||||||
creator() {
|
creator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
creator(const creator<U>&) {
|
creator(const creator<U>&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
T* allocate(std::size_t size) {
|
T* allocate(std::size_t size) {
|
||||||
void* p1 = ::operator new(size * sizeof(T));
|
void* p = ::operator new(size * sizeof(T));
|
||||||
return static_cast<T*>(p1);
|
return static_cast<T*>(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deallocate(T* memory, std::size_t) {
|
void deallocate(T* memory, std::size_t) {
|
||||||
void* p1 = memory;
|
void* p = memory;
|
||||||
::operator delete(p1);
|
::operator delete(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
void construct(U* memory) {
|
void construct(U* memory) {
|
||||||
void* p1 = memory;
|
void* p = memory;
|
||||||
::new(p1) U();
|
::new(p) U(tag());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
void destroy(U* memory) {
|
void destroy(U* memory) {
|
||||||
memory->~U();
|
memory->~U();
|
||||||
@@ -45,116 +40,88 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
friend class creator<type>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
static const type object;
|
explicit type(tag) {
|
||||||
|
|
||||||
protected:
|
|
||||||
explicit type() {
|
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
type(const type&) {
|
type(const type&) {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int type::instances;
|
unsigned int type::instances = 0;
|
||||||
const type type::object;
|
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
BOOST_TEST(type::instances == 1);
|
{
|
||||||
|
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(creator<void>(), 3);
|
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(creator<void>(), 3);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(type::instances == 4);
|
BOOST_TEST(type::instances == 3);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(creator<void>());
|
boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(creator<void>());
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(type::instances == 4);
|
BOOST_TEST(type::instances == 3);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(creator<void>(), 2);
|
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(creator<void>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 5);
|
BOOST_TEST(type::instances == 4);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(creator<void>());
|
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(creator<void>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 5);
|
BOOST_TEST(type::instances == 4);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(creator<void>(), 3);
|
boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(creator<void>(), 3);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 4);
|
BOOST_TEST(type::instances == 3);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared<const type[3]>(creator<void>());
|
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared<const type[3]>(creator<void>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 4);
|
BOOST_TEST(type::instances == 3);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared<const type[][2]>(creator<void>(), 2);
|
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared<const type[][2]>(creator<void>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 5);
|
BOOST_TEST(type::instances == 4);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 1);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared<const type[2][2]>(creator<void>());
|
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared<const type[2][2]>(creator<void>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
BOOST_TEST(type::instances == 5);
|
BOOST_TEST(type::instances == 4);
|
||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 1);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
|
||||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
class type
|
class type
|
||||||
: public boost::enable_shared_from_this<type> {
|
: public boost::enable_shared_from_this<type> {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), 3);
|
||||||
@@ -41,7 +39,6 @@ int main() {
|
|||||||
BOOST_TEST(type::instances == 3);
|
BOOST_TEST(type::instances == 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
|
||||||
@@ -52,6 +49,5 @@ int main() {
|
|||||||
BOOST_TEST(type::instances == 3);
|
BOOST_TEST(type::instances == 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::allocate_shared_noinit<int[]>(std::allocator<int>(), 3);
|
boost::shared_ptr<int[]> a1 = boost::allocate_shared_noinit<int[]>(std::allocator<int>(), 3);
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -38,7 +36,6 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[3]> a1 = boost::allocate_shared_noinit<int[3]>(std::allocator<int>());
|
boost::shared_ptr<int[3]> a1 = boost::allocate_shared_noinit<int[3]>(std::allocator<int>());
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -46,19 +43,16 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared_noinit<int[][2]>(std::allocator<int>(), 2);
|
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared_noinit<int[][2]>(std::allocator<int>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared_noinit<int[2][2]>(std::allocator<int>());
|
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared_noinit<int[2][2]>(std::allocator<int>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::allocate_shared_noinit<const int[]>(std::allocator<int>(), 3);
|
boost::shared_ptr<const int[]> a1 = boost::allocate_shared_noinit<const int[]>(std::allocator<int>(), 3);
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -66,7 +60,6 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[3]> a1 = boost::allocate_shared_noinit<const int[3]>(std::allocator<int>());
|
boost::shared_ptr<const int[3]> a1 = boost::allocate_shared_noinit<const int[3]>(std::allocator<int>());
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -74,20 +67,16 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared_noinit<const int[][2]>(std::allocator<int>(), 2);
|
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared_noinit<const int[][2]>(std::allocator<int>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared_noinit<const int[2][2]>(std::allocator<int>());
|
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared_noinit<const int[2][2]>(std::allocator<int>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<type[]> a1 = boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 3);
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -99,8 +88,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[3]> a1 = boost::allocate_shared_noinit<type[3]>(std::allocator<type>());
|
boost::shared_ptr<type[3]> a1 = boost::allocate_shared_noinit<type[3]>(std::allocator<type>());
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -112,8 +99,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 2);
|
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -122,8 +107,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared_noinit<type[2][2]>(std::allocator<type>());
|
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared_noinit<type[2][2]>(std::allocator<type>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -132,8 +115,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[]> a1 = boost::allocate_shared_noinit<const type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<const type[]> a1 = boost::allocate_shared_noinit<const type[]>(std::allocator<type>(), 3);
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -144,8 +125,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared_noinit<const type[3]>(std::allocator<type>());
|
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared_noinit<const type[3]>(std::allocator<type>());
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -156,8 +135,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared_noinit<const type[][2]>(std::allocator<type>(), 2);
|
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared_noinit<const type[][2]>(std::allocator<type>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -166,8 +143,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared_noinit<const type[2][2]>(std::allocator<type>());
|
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared_noinit<const type[2][2]>(std::allocator<type>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -176,6 +151,5 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), 3);
|
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), 3);
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -41,7 +39,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[3]> a1 = boost::allocate_shared<int[3]>(std::allocator<int>());
|
boost::shared_ptr<int[3]> a1 = boost::allocate_shared<int[3]>(std::allocator<int>());
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -52,7 +49,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2);
|
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -62,7 +58,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>());
|
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -72,7 +67,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), 3);
|
boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), 3);
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -83,7 +77,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[3]> a1 = boost::allocate_shared<const int[3]>(std::allocator<int>());
|
boost::shared_ptr<const int[3]> a1 = boost::allocate_shared<const int[3]>(std::allocator<int>());
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -94,7 +87,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared<const int[][2]>(std::allocator<int>(), 2);
|
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared<const int[][2]>(std::allocator<int>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -104,7 +96,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared<const int[2][2]>(std::allocator<int>());
|
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared<const int[2][2]>(std::allocator<int>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -114,8 +105,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), 3);
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -127,8 +116,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(std::allocator<type>());
|
boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(std::allocator<type>());
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -140,8 +127,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(std::allocator<type>(), 2);
|
boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(std::allocator<type>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -150,8 +135,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(std::allocator<type>());
|
boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(std::allocator<type>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -160,8 +143,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(std::allocator<type>(), 3);
|
boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(std::allocator<type>(), 3);
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -172,8 +153,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared<const type[3]>(std::allocator<type>());
|
boost::shared_ptr<const type[3]> a1 = boost::allocate_shared<const type[3]>(std::allocator<type>());
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -184,8 +163,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared<const type[][2]>(std::allocator<type>(), 2);
|
boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared<const type[][2]>(std::allocator<type>(), 2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -194,8 +171,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared<const type[2][2]>(std::allocator<type>());
|
boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared<const type[2][2]>(std::allocator<type>());
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -204,6 +179,5 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,29 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
if (instances == 5) {
|
if (instances == 5) {
|
||||||
throw true;
|
throw true;
|
||||||
}
|
}
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -31,70 +28,55 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
BOOST_TEST(type::instances == 0);
|
{
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared<type[]>(std::allocator<type>(), 6);
|
boost::allocate_shared<type[]>(std::allocator<type>(), 6);
|
||||||
BOOST_ERROR("allocate_shared did not throw");
|
BOOST_ERROR("allocate_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared<type[][2]>(std::allocator<type>(), 3);
|
boost::allocate_shared<type[][2]>(std::allocator<type>(), 3);
|
||||||
BOOST_ERROR("allocate_shared did not throw");
|
BOOST_ERROR("allocate_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared<type[6]>(std::allocator<type>());
|
boost::allocate_shared<type[6]>(std::allocator<type>());
|
||||||
BOOST_ERROR("allocate_shared did not throw");
|
BOOST_ERROR("allocate_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared<type[3][2]>(std::allocator<type>());
|
boost::allocate_shared<type[3][2]>(std::allocator<type>());
|
||||||
BOOST_ERROR("allocate_shared did not throw");
|
BOOST_ERROR("allocate_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 6);
|
boost::allocate_shared_noinit<type[]>(std::allocator<type>(), 6);
|
||||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 3);
|
boost::allocate_shared_noinit<type[][2]>(std::allocator<type>(), 3);
|
||||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared_noinit<type[6]>(std::allocator<type>());
|
boost::allocate_shared_noinit<type[6]>(std::allocator<type>());
|
||||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::allocate_shared_noinit<type[3][2]>(std::allocator<type>());
|
boost::allocate_shared_noinit<type[3][2]>(std::allocator<type>());
|
||||||
BOOST_ERROR("allocate_shared_noinit did not throw");
|
BOOST_ERROR("allocate_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
|
||||||
|
|
||||||
int main() {
|
Distributed under the Boost Software
|
||||||
|
License, Version 1.0.
|
||||||
|
http://boost.org/LICENSE_1_0.txt
|
||||||
|
*/
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), 4, 1);
|
boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), 4, 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -17,7 +18,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), 1);
|
boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -25,7 +25,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), 4, 1);
|
boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), 4, 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -33,7 +32,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[4]> a1 = boost::allocate_shared<const int[4]>(std::allocator<int>(), 1);
|
boost::shared_ptr<const int[4]> a1 = boost::allocate_shared<const int[4]>(std::allocator<int>(), 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -41,6 +39,5 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
|
||||||
|
|
||||||
int main() {
|
Distributed under the Boost Software
|
||||||
|
License, Version 1.0.
|
||||||
|
http://boost.org/LICENSE_1_0.txt
|
||||||
|
*/
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2, {0, 1});
|
boost::shared_ptr<int[][2]> a1 = boost::allocate_shared<int[][2]>(std::allocator<int>(), 2, {0, 1});
|
||||||
@@ -18,7 +19,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>(), { 0, 1 });
|
boost::shared_ptr<int[2][2]> a1 = boost::allocate_shared<int[2][2]>(std::allocator<int>(), { 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -26,7 +26,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared<const int[][2]>(std::allocator<int>(), 2, { 0, 1 });
|
boost::shared_ptr<const int[][2]> a1 = boost::allocate_shared<const int[][2]>(std::allocator<int>(), 2, { 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -34,7 +33,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared<const int[2][2]>(std::allocator<int>(), { 0, 1 });
|
boost::shared_ptr<const int[2][2]> a1 = boost::allocate_shared<const int[2][2]>(std::allocator<int>(), { 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -43,6 +41,5 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -143,6 +143,18 @@ int main()
|
|||||||
BOOST_TEST( N::base::instances == 0 );
|
BOOST_TEST( N::base::instances == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::intrusive_ptr<Y> p( new Y );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
|
||||||
|
boost::intrusive_ptr<X> p2( std::move( p ) );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
|
||||||
|
p2.reset();
|
||||||
|
BOOST_TEST( N::base::instances == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::intrusive_ptr<X> p( new X );
|
boost::intrusive_ptr<X> p( new X );
|
||||||
BOOST_TEST( N::base::instances == 1 );
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
@@ -170,6 +182,33 @@ int main()
|
|||||||
BOOST_TEST( N::base::instances == 0 );
|
BOOST_TEST( N::base::instances == 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::intrusive_ptr<Y> p( new Y );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
|
||||||
|
boost::intrusive_ptr<X> p2;
|
||||||
|
p2 = std::move( p );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
|
||||||
|
p2.reset();
|
||||||
|
BOOST_TEST( N::base::instances == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::intrusive_ptr<Y> p( new Y );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
|
||||||
|
boost::intrusive_ptr<X> p2( new X );
|
||||||
|
BOOST_TEST( N::base::instances == 2 );
|
||||||
|
p2 = std::move( p );
|
||||||
|
BOOST_TEST( N::base::instances == 1 );
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
|
||||||
|
p2.reset();
|
||||||
|
BOOST_TEST( N::base::instances == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
#include <boost/smart_ptr/enable_shared_from_this.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
class type
|
class type
|
||||||
: public boost::enable_shared_from_this<type> {
|
: public boost::enable_shared_from_this<type> {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3);
|
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3);
|
||||||
@@ -41,7 +39,6 @@ int main() {
|
|||||||
BOOST_TEST(type::instances == 3);
|
BOOST_TEST(type::instances == 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(3);
|
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(3);
|
||||||
@@ -52,6 +49,5 @@ int main() {
|
|||||||
BOOST_TEST(type::instances == 3);
|
BOOST_TEST(type::instances == 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(3);
|
boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(3);
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -38,7 +36,6 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[3]> a1 = boost::make_shared_noinit<int[3]>();
|
boost::shared_ptr<int[3]> a1 = boost::make_shared_noinit<int[3]>();
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -46,19 +43,16 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::make_shared_noinit<int[][2]>(2);
|
boost::shared_ptr<int[][2]> a1 = boost::make_shared_noinit<int[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::make_shared_noinit<int[2][2]>();
|
boost::shared_ptr<int[2][2]> a1 = boost::make_shared_noinit<int[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::make_shared_noinit<const int[]>(3);
|
boost::shared_ptr<const int[]> a1 = boost::make_shared_noinit<const int[]>(3);
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -66,7 +60,6 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[3]> a1 = boost::make_shared_noinit<const int[3]>();
|
boost::shared_ptr<const int[3]> a1 = boost::make_shared_noinit<const int[3]>();
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -74,20 +67,16 @@ int main() {
|
|||||||
BOOST_TEST(a2 != 0);
|
BOOST_TEST(a2 != 0);
|
||||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::make_shared_noinit<const int[][2]>(2);
|
boost::shared_ptr<const int[][2]> a1 = boost::make_shared_noinit<const int[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared_noinit<const int[2][2]>();
|
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared_noinit<const int[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
BOOST_TEST(a1.use_count() == 1);
|
BOOST_TEST(a1.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(3);
|
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(3);
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -99,8 +88,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[3]> a1 = boost::make_shared_noinit<type[3]>();
|
boost::shared_ptr<type[3]> a1 = boost::make_shared_noinit<type[3]>();
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -112,8 +99,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[][2]> a1 = boost::make_shared_noinit<type[][2]>(2);
|
boost::shared_ptr<type[][2]> a1 = boost::make_shared_noinit<type[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -122,8 +107,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[2][2]> a1 = boost::make_shared_noinit<type[2][2]>();
|
boost::shared_ptr<type[2][2]> a1 = boost::make_shared_noinit<type[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -132,8 +115,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[]> a1 = boost::make_shared_noinit<const type[]>(3);
|
boost::shared_ptr<const type[]> a1 = boost::make_shared_noinit<const type[]>(3);
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -144,8 +125,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[3]> a1 = boost::make_shared_noinit<const type[3]>();
|
boost::shared_ptr<const type[3]> a1 = boost::make_shared_noinit<const type[3]>();
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -156,8 +135,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[][2]> a1 = boost::make_shared_noinit<const type[][2]>(2);
|
boost::shared_ptr<const type[][2]> a1 = boost::make_shared_noinit<const type[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -166,8 +143,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[2][2]> a1 = boost::make_shared_noinit<const type[2][2]>();
|
boost::shared_ptr<const type[2][2]> a1 = boost::make_shared_noinit<const type[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -176,6 +151,5 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,25 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -30,7 +27,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(3);
|
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(3);
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -41,7 +39,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[3]> a1 = boost::make_shared<int[3]>();
|
boost::shared_ptr<int[3]> a1 = boost::make_shared<int[3]>();
|
||||||
int* a2 = a1.get();
|
int* a2 = a1.get();
|
||||||
@@ -52,7 +49,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2);
|
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -62,7 +58,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>();
|
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -72,7 +67,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>(3);
|
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>(3);
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -83,7 +77,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[3]> a1 = boost::make_shared<const int[3]>();
|
boost::shared_ptr<const int[3]> a1 = boost::make_shared<const int[3]>();
|
||||||
const int* a2 = a1.get();
|
const int* a2 = a1.get();
|
||||||
@@ -94,7 +87,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1] == 0);
|
BOOST_TEST(a1[1] == 0);
|
||||||
BOOST_TEST(a1[2] == 0);
|
BOOST_TEST(a1[2] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::make_shared<const int[][2]>(2);
|
boost::shared_ptr<const int[][2]> a1 = boost::make_shared<const int[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -104,7 +96,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared<const int[2][2]>();
|
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared<const int[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -114,8 +105,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 0);
|
BOOST_TEST(a1[1][1] == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3);
|
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3);
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -127,8 +116,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[3]> a1 = boost::make_shared<type[3]>();
|
boost::shared_ptr<type[3]> a1 = boost::make_shared<type[3]>();
|
||||||
type* a2 = a1.get();
|
type* a2 = a1.get();
|
||||||
@@ -140,8 +127,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[][2]> a1 = boost::make_shared<type[][2]>(2);
|
boost::shared_ptr<type[][2]> a1 = boost::make_shared<type[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -150,8 +135,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<type[2][2]> a1 = boost::make_shared<type[2][2]>();
|
boost::shared_ptr<type[2][2]> a1 = boost::make_shared<type[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -160,8 +143,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>(3);
|
boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>(3);
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -172,8 +153,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[3]> a1 = boost::make_shared<const type[3]>();
|
boost::shared_ptr<const type[3]> a1 = boost::make_shared<const type[3]>();
|
||||||
const type* a2 = a1.get();
|
const type* a2 = a1.get();
|
||||||
@@ -184,8 +163,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[][2]> a1 = boost::make_shared<const type[][2]>(2);
|
boost::shared_ptr<const type[][2]> a1 = boost::make_shared<const type[][2]>(2);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -194,8 +171,6 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const type[2][2]> a1 = boost::make_shared<const type[2][2]>();
|
boost::shared_ptr<const type[2][2]> a1 = boost::make_shared<const type[2][2]>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -204,6 +179,5 @@ int main() {
|
|||||||
a1.reset();
|
a1.reset();
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,29 +1,26 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
static unsigned int instances;
|
static unsigned int instances;
|
||||||
|
|
||||||
explicit type() {
|
explicit type() {
|
||||||
if (instances == 5) {
|
if (instances == 5) {
|
||||||
throw true;
|
throw true;
|
||||||
}
|
}
|
||||||
instances++;
|
instances++;
|
||||||
}
|
}
|
||||||
|
|
||||||
~type() {
|
~type() {
|
||||||
instances--;
|
instances--;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
type(const type&);
|
type(const type&);
|
||||||
type& operator=(const type&);
|
type& operator=(const type&);
|
||||||
@@ -31,70 +28,55 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
BOOST_TEST(type::instances == 0);
|
{
|
||||||
try {
|
try {
|
||||||
boost::make_shared<type[]>(6);
|
boost::make_shared<type[]>(6);
|
||||||
BOOST_ERROR("make_shared did not throw");
|
BOOST_ERROR("make_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared<type[][2]>(3);
|
boost::make_shared<type[][2]>(3);
|
||||||
BOOST_ERROR("make_shared did not throw");
|
BOOST_ERROR("make_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared<type[6]>();
|
boost::make_shared<type[6]>();
|
||||||
BOOST_ERROR("make_shared did not throw");
|
BOOST_ERROR("make_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared<type[3][2]>();
|
boost::make_shared<type[3][2]>();
|
||||||
BOOST_ERROR("make_shared did not throw");
|
BOOST_ERROR("make_shared did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared_noinit<type[]>(6);
|
boost::make_shared_noinit<type[]>(6);
|
||||||
BOOST_ERROR("make_shared_noinit did not throw");
|
BOOST_ERROR("make_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared_noinit<type[][2]>(3);
|
boost::make_shared_noinit<type[][2]>(3);
|
||||||
BOOST_ERROR("make_shared_noinit did not throw");
|
BOOST_ERROR("make_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared_noinit<type[6]>();
|
boost::make_shared_noinit<type[6]>();
|
||||||
BOOST_ERROR("make_shared_noinit did not throw");
|
BOOST_ERROR("make_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_TEST(type::instances == 0);
|
|
||||||
try {
|
try {
|
||||||
boost::make_shared_noinit<type[3][2]>();
|
boost::make_shared_noinit<type[3][2]>();
|
||||||
BOOST_ERROR("make_shared_noinit did not throw");
|
BOOST_ERROR("make_shared_noinit did not throw");
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
|
||||||
|
|
||||||
int main() {
|
Distributed under the Boost Software
|
||||||
|
License, Version 1.0.
|
||||||
|
http://boost.org/LICENSE_1_0.txt
|
||||||
|
*/
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(4, 1);
|
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(4, 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -17,7 +18,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>(1);
|
boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>(1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -25,7 +25,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>(4, 1);
|
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>(4, 1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -33,7 +32,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[4]> a1 = boost::make_shared<const int[4]>(1);
|
boost::shared_ptr<const int[4]> a1 = boost::make_shared<const int[4]>(1);
|
||||||
BOOST_TEST(a1[0] == 1);
|
BOOST_TEST(a1[0] == 1);
|
||||||
@@ -41,6 +39,5 @@ int main() {
|
|||||||
BOOST_TEST(a1[2] == 1);
|
BOOST_TEST(a1[2] == 1);
|
||||||
BOOST_TEST(a1[3] == 1);
|
BOOST_TEST(a1[3] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2012-2015 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
|
||||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
|
||||||
|
|
||||||
int main() {
|
Distributed under the Boost Software
|
||||||
|
License, Version 1.0.
|
||||||
|
http://boost.org/LICENSE_1_0.txt
|
||||||
|
*/
|
||||||
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2, {0, 1});
|
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2, {0, 1});
|
||||||
@@ -18,7 +19,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>({ 0, 1 });
|
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>({ 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -26,7 +26,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[][2]> a1 = boost::make_shared<const int[][2]>(2, { 0, 1 });
|
boost::shared_ptr<const int[][2]> a1 = boost::make_shared<const int[][2]>(2, { 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -34,7 +33,6 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][0] == 0);
|
BOOST_TEST(a1[1][0] == 0);
|
||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared<const int[2][2]>({ 0, 1 });
|
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared<const int[2][2]>({ 0, 1 });
|
||||||
BOOST_TEST(a1[0][0] == 0);
|
BOOST_TEST(a1[0][0] == 0);
|
||||||
@@ -43,6 +41,5 @@ int main() {
|
|||||||
BOOST_TEST(a1[1][1] == 1);
|
BOOST_TEST(a1[1][1] == 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -41,7 +41,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
{
|
{
|
||||||
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
||||||
@@ -139,7 +140,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -30,7 +30,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::unique_ptr<int[]> a1 = boost::make_unique_noinit<int[]>(3);
|
std::unique_ptr<int[]> a1 = boost::make_unique_noinit<int[]>(3);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -81,7 +82,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -30,7 +30,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::unique_ptr<int[]> a1 = boost::make_unique<int[]>(3);
|
std::unique_ptr<int[]> a1 = boost::make_unique<int[]>(3);
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -105,7 +106,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_array.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
try {
|
try {
|
||||||
boost::make_unique<type[]>(6);
|
boost::make_unique<type[]>(6);
|
||||||
@@ -70,7 +71,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -30,7 +30,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::unique_ptr<int> a1 = boost::make_unique_noinit<int>();
|
std::unique_ptr<int> a1 = boost::make_unique_noinit<int>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -58,7 +59,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -30,7 +30,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::unique_ptr<int> a1 = boost::make_unique<int>();
|
std::unique_ptr<int> a1 = boost::make_unique<int>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -65,7 +66,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
class type {
|
class type {
|
||||||
public:
|
public:
|
||||||
@@ -33,7 +33,8 @@ private:
|
|||||||
|
|
||||||
unsigned int type::instances = 0;
|
unsigned int type::instances = 0;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_TEST(type::instances == 0);
|
BOOST_TEST(type::instances == 0);
|
||||||
try {
|
try {
|
||||||
boost::make_unique<type>();
|
boost::make_unique<type>();
|
||||||
@@ -46,7 +47,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,22 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Glen Joseph Fernandes
|
(c) 2014 Glen Joseph Fernandes
|
||||||
* glenfe at live dot com
|
<glenjofe -at- gmail.com>
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License,
|
Distributed under the Boost Software
|
||||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
License, Version 1.0.
|
||||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
http://boost.org/LICENSE_1_0.txt
|
||||||
*/
|
*/
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
#if !defined(BOOST_NO_CXX11_SMART_PTR)
|
||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <boost/smart_ptr/make_unique_object.hpp>
|
#include <boost/smart_ptr/make_unique.hpp>
|
||||||
|
|
||||||
struct type {
|
struct type {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
{
|
{
|
||||||
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
std::unique_ptr<type> a1 = boost::make_unique<type>();
|
||||||
BOOST_TEST(a1.get() != 0);
|
BOOST_TEST(a1.get() != 0);
|
||||||
@@ -51,7 +52,8 @@ int main() {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
255
test/shared_ptr_alias_move_test.cpp
Normal file
255
test/shared_ptr_alias_move_test.cpp
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
|
// shared_ptr_alias_move_test.cpp
|
||||||
|
//
|
||||||
|
// Copyright (c) 2007 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/detail/lightweight_test.hpp>
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||||
|
|
||||||
|
class incomplete;
|
||||||
|
|
||||||
|
struct X
|
||||||
|
{
|
||||||
|
static long instances;
|
||||||
|
|
||||||
|
int v_;
|
||||||
|
|
||||||
|
explicit X( int v ): v_( v )
|
||||||
|
{
|
||||||
|
++instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
~X()
|
||||||
|
{
|
||||||
|
v_ = 0;
|
||||||
|
--instances;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
X( X const & );
|
||||||
|
X & operator=( X const & );
|
||||||
|
};
|
||||||
|
|
||||||
|
long X::instances = 0;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
BOOST_TEST( X::instances == 0 );
|
||||||
|
|
||||||
|
{
|
||||||
|
int m = 0;
|
||||||
|
boost::shared_ptr< int > p;
|
||||||
|
boost::shared_ptr< int > p2( std::move( p ), &m );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &m );
|
||||||
|
BOOST_TEST( p2? true: false );
|
||||||
|
BOOST_TEST( !!p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
|
||||||
|
p2.reset( std::move( p ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2? false: true );
|
||||||
|
BOOST_TEST( !p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int m = 0;
|
||||||
|
boost::shared_ptr< int > p( new int );
|
||||||
|
boost::shared_ptr< int const > p2( std::move( p ), &m );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &m );
|
||||||
|
BOOST_TEST( p2? true: false );
|
||||||
|
BOOST_TEST( !!p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
|
||||||
|
boost::shared_ptr< int volatile > p3;
|
||||||
|
p2.reset( std::move( p3 ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2? false: true );
|
||||||
|
BOOST_TEST( !p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p3.get() == 0 );
|
||||||
|
BOOST_TEST( p3.use_count() == 0 );
|
||||||
|
|
||||||
|
boost::shared_ptr< int const volatile > p4( new int );
|
||||||
|
p2.reset( std::move( p4 ), &m );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &m );
|
||||||
|
BOOST_TEST( p2.use_count() == 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( p4.get() == 0 );
|
||||||
|
BOOST_TEST( p4.use_count() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< int > p( new int );
|
||||||
|
boost::shared_ptr< void const > p2( std::move( p ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2? false: true );
|
||||||
|
BOOST_TEST( !p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
|
||||||
|
int m = 0;
|
||||||
|
boost::shared_ptr< void volatile > p3;
|
||||||
|
|
||||||
|
p2.reset( std::move( p3 ), &m );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &m );
|
||||||
|
BOOST_TEST( p2? true: false );
|
||||||
|
BOOST_TEST( !!p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p3.get() == 0 );
|
||||||
|
BOOST_TEST( p3.use_count() == 0 );
|
||||||
|
|
||||||
|
boost::shared_ptr< void const volatile > p4( new int );
|
||||||
|
p2.reset( std::move( p4 ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2.use_count() == 1 );
|
||||||
|
|
||||||
|
BOOST_TEST( p4.get() == 0 );
|
||||||
|
BOOST_TEST( p4.use_count() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< incomplete > p;
|
||||||
|
boost::shared_ptr< incomplete > p2( std::move( p ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2? false: true );
|
||||||
|
BOOST_TEST( !p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
|
||||||
|
p2.reset( std::move( p ), 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p2? false: true );
|
||||||
|
BOOST_TEST( !p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p.use_count() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< X > p( new X( 5 ) ), q( p );
|
||||||
|
boost::shared_ptr< int const > p2( std::move( q ), &q->v_ );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &p->v_ );
|
||||||
|
BOOST_TEST( p2? true: false );
|
||||||
|
BOOST_TEST( !!p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == p.use_count() );
|
||||||
|
BOOST_TEST( !( p < p2 ) && !( p2 < p ) );
|
||||||
|
|
||||||
|
BOOST_TEST( q.get() == 0 );
|
||||||
|
BOOST_TEST( q.use_count() == 0 );
|
||||||
|
|
||||||
|
p.reset();
|
||||||
|
BOOST_TEST( *p2 == 5 );
|
||||||
|
|
||||||
|
boost::shared_ptr< X const > p3( new X( 8 ) ), q3( p3 );
|
||||||
|
p2.reset( std::move( q3 ), &q3->v_ );
|
||||||
|
|
||||||
|
BOOST_TEST( p2.get() == &p3->v_ );
|
||||||
|
BOOST_TEST( p2? true: false );
|
||||||
|
BOOST_TEST( !!p2 );
|
||||||
|
BOOST_TEST( p2.use_count() == p3.use_count() );
|
||||||
|
BOOST_TEST( !( p3 < p2 ) && !( p2 < p3 ) );
|
||||||
|
|
||||||
|
BOOST_TEST( q3.get() == 0 );
|
||||||
|
BOOST_TEST( q3.use_count() == 0 );
|
||||||
|
|
||||||
|
p3.reset();
|
||||||
|
BOOST_TEST( *p2 == 8 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< X > p( new X( 5 ) );
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.unique() );
|
||||||
|
BOOST_TEST( p->v_ == 5 );
|
||||||
|
|
||||||
|
boost::shared_ptr< X > p2( std::move( p ), p.get() );
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.get() == 0 );
|
||||||
|
BOOST_TEST( p2.unique() );
|
||||||
|
BOOST_TEST( p2->v_ == 5 );
|
||||||
|
|
||||||
|
boost::shared_ptr< int const > p3( std::move( p2 ), &p2->v_ );
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p3.unique() );
|
||||||
|
BOOST_TEST( *p3 == 5 );
|
||||||
|
|
||||||
|
p3.reset();
|
||||||
|
BOOST_TEST( X::instances == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< X > p( new X( 5 ) );
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.unique() );
|
||||||
|
BOOST_TEST( p->v_ == 5 );
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::shared_ptr< X > p2(p);
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.get() == p2.get() );
|
||||||
|
BOOST_TEST( p.use_count() == 2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 2 );
|
||||||
|
|
||||||
|
boost::shared_ptr< int const > p3( std::move( p2 ), &p2->v_ );
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.use_count() == 2 );
|
||||||
|
BOOST_TEST( p2.use_count() == 0 );
|
||||||
|
BOOST_TEST( p2.get() == 0 );
|
||||||
|
BOOST_TEST( p3.use_count() == 2 );
|
||||||
|
BOOST_TEST( p3.get() == &p->v_ );
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_TEST( X::instances == 1 );
|
||||||
|
BOOST_TEST( p.unique() );
|
||||||
|
BOOST_TEST( p->v_ == 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
34
test/sp_hash_test2.cpp
Normal file
34
test/sp_hash_test2.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// sp_hash_test2.cpp
|
||||||
|
//
|
||||||
|
// Copyright 2011, 2015 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/functional/hash.hpp>
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::hash< boost::shared_ptr<int[]> > hasher;
|
||||||
|
|
||||||
|
boost::shared_ptr< int[] > p1, p2( p1 ), p3( new int[1] ), p4( p3 ), p5( new int[1] );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p1, p2 );
|
||||||
|
BOOST_TEST_EQ( hasher( p1 ), hasher( p2 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_NE( p1, p3 );
|
||||||
|
BOOST_TEST_NE( hasher( p1 ), hasher( p3 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p3, p4 );
|
||||||
|
BOOST_TEST_EQ( hasher( p3 ), hasher( p4 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_NE( p3, p5 );
|
||||||
|
BOOST_TEST_NE( hasher( p3 ), hasher( p5 ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
34
test/sp_hash_test3.cpp
Normal file
34
test/sp_hash_test3.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
//
|
||||||
|
// sp_hash_test3.cpp
|
||||||
|
//
|
||||||
|
// Copyright 2011, 2015 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/functional/hash.hpp>
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::hash< boost::shared_ptr<int[1]> > hasher;
|
||||||
|
|
||||||
|
boost::shared_ptr< int[1] > p1, p2( p1 ), p3( new int[1] ), p4( p3 ), p5( new int[1] );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p1, p2 );
|
||||||
|
BOOST_TEST_EQ( hasher( p1 ), hasher( p2 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_NE( p1, p3 );
|
||||||
|
BOOST_TEST_NE( hasher( p1 ), hasher( p3 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( p3, p4 );
|
||||||
|
BOOST_TEST_EQ( hasher( p3 ), hasher( p4 ) );
|
||||||
|
|
||||||
|
BOOST_TEST_NE( p3, p5 );
|
||||||
|
BOOST_TEST_NE( hasher( p3 ), hasher( p5 ) );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user