Compare commits

...

22 Commits

Author SHA1 Message Date
Peter Dimov
06bd43d5b5 Merge branch 'develop' 2017-07-13 16:36:43 +03:00
Glen Fernandes
1758d44e4c Add basic synopsis and description for make_local_shared 2017-07-08 08:50:59 -04:00
Peter Dimov
1c13ec0888 Remove wrong doc link from meta/libraries.json 2017-07-07 17:58:49 +03:00
Peter Dimov
cc7eb56f51 Fixed broken link in techniques.adoc 2017-07-07 14:14:54 +03:00
Peter Dimov
eb64ae8daa Untabify pointer_cast_test2 2017-07-07 00:59:01 +03:00
Glen Fernandes
a3c8c2125a Use has_trivial_assign in construction utilities 2017-07-04 13:45:56 -04:00
Glen Fernandes
3aa419463c Simplify lsp state types 2017-07-01 10:00:47 -04:00
Glen Fernandes
e4ba116d7e Minor refactoring in allocate_shared implementations 2017-06-29 22:33:43 -04:00
Glen Fernandes
864a0c80dd Conditionally compile allocate_local_shared tests 2017-06-29 13:33:14 -04:00
Glen Fernandes
be736e5088 Implement allocate_local_shared for arrays
Also fix the local_shared_ptr constructor to use element_type
2017-06-29 13:05:03 -04:00
Glen Fernandes
48294c483f Use new shared_count constructors in allocate_shared 2017-06-29 09:24:02 -04:00
Peter Dimov
13e73d6a78 Do not use UINT_MAX to avoid -Wmicrosoft-enum-value from Clang 2017-06-27 16:23:18 +03:00
Peter Dimov
20a517cc3d Clang/C2 doesn't have _mm_pause 2017-06-27 15:41:56 +03:00
Peter Dimov
65d412c840 Execute bootstrap in subshell on Appveyor to preserve TOOLSET 2017-06-22 17:34:20 +03:00
Peter Dimov
d031d4719f Check use counts in make_local_shared tests 2017-06-22 15:39:46 +03:00
Peter Dimov
c1979bcaf5 Check use counts in make_shared tests 2017-06-22 15:31:50 +03:00
Peter Dimov
0adb1fb212 Add shared_count constructor taking sp_counted_base* 2017-06-22 15:24:49 +03:00
Peter Dimov
7410cb1733 Update history.adoc. 2017-06-21 20:25:37 +03:00
Peter Dimov
2d087d0003 Do not use A::destroy in allocate_shared_noinit 2017-06-21 13:44:17 +03:00
Peter Dimov
ca7a01a593 Add more tests. Update Jamfile to new style. 2017-06-21 04:07:17 +03:00
Peter Dimov
314a6634d4 Merge branch 'feature/local_shared_ptr' into develop 2017-06-21 03:33:00 +03:00
Glen Fernandes
6cbc1e6775 Update allocate_shared array unit tests
Tests that do not always use allocator bound for element_type.
2017-06-20 20:06:59 -04:00
46 changed files with 3311 additions and 1081 deletions

View File

@@ -50,7 +50,7 @@ install:
- git submodule init tools/build
- git submodule update
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\smart_ptr
- bootstrap
- cmd /c bootstrap
- b2 headers
build: off

View File

@@ -39,6 +39,8 @@ include::smart_ptr/intrusive_ref_counter.adoc[]
include::smart_ptr/local_shared_ptr.adoc[]
include::smart_ptr/make_local_shared.adoc[]
include::smart_ptr/pointer_cast.adoc[]
include::smart_ptr/pointer_to_other.adoc[]

View File

@@ -110,4 +110,4 @@ Glen Fernandes rewrote `allocate_shared` and `make_shared` for arrays for a more
Peter Dimov and Glen Fernandes rewrote the documentation in Asciidoc format.
Peter Dimov added `atomic_shared_ptr`.
Peter Dimov added `atomic_shared_ptr` and `local_shared_ptr`.

View File

@@ -0,0 +1,81 @@
////
Copyright 2017 Glen Joseph Fernandes (glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
////
[#make_local_shared]
# make_local_shared: Creating local_shared_ptr
:toc:
:toc-title:
:idprefix: make_local_shared_
## Description
The function templates `make_local_shared` and `allocate_local_shared` provide
convenient, safe and efficient ways to create `local_shared_ptr` objects. They
are analogous to `make_shared` and `allocate_shared` for `shared_ptr`.
## Synopsis
`make_local_shared` and `allocate_local_shared` are defined in
`<boost/smart_ptr/make_local_shared.hpp>`.
[subs=+quotes]
```
namespace boost {
`// only if T is not an array type`
template<class T, class... Args>
local_shared_ptr<T> make_local_shared(Args&&... args);
template<class T, class A, class... Args>
local_shared_ptr<T> allocate_local_shared(const A& a, Args&&... args);
`// only if T is an array type of the form U[]`
template<class T>
local_shared_ptr<T> make_local_shared(std::size_t n);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n);
`// only if T is an array type of the form U[N]`
template<class T>
local_shared_ptr<T> make_local_shared();
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a);
`// only if T is an array type of the form U[]`
template<class T>
local_shared_ptr<T> make_local_shared(std::size_t n,
const remove_extent_t<T>& v);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a, std::size_t n,
const remove_extent_t<T>& v);
`// only if T is an array type of the form U[N]`
template<class T>
local_shared_ptr<T> make_local_shared(const remove_extent_t<T>& v);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared(const A& a,
const remove_extent_t<T>& v);
`// only if T is not an array type of the form U[]`
template<class T>
local_shared_ptr<T> make_local_shared_noinit();
template<class T, class A>
local_shared_ptr<T> allocate_local_shared_noinit(const A& a);
`// only if T is an array type of the form U[N]`
template<class T>
local_shared_ptr<T> make_local_shared_noinit(std::size_t n);
template<class T, class A>
local_shared_ptr<T> allocate_local_shared_noinit(const A& a,
std::size_t n);
}
```
## Description
The requirements and effects of these functions are the same as `make_shared`
and `allocate_shared`, except that a `local_shared_ptr` is returned.

View File

@@ -251,7 +251,7 @@ Note, however, that `shared_ptr` copies created from `pw` will not "register" in
they will share the single reference created in `make_shared_from_COM`. Weak pointers created from `pw` will be invalidated when the last
`shared_ptr` is destroyed, regardless of whether the COM object itself is still alive.
As link:../../libs/bind/mem_fn.html#Q3[explained] in the `mem_fn` documentation, you need to `#define BOOST_MEM_FN_ENABLE_STDCALL` first.
As link:../../../../libs/bind/mem_fn.html#Q3[explained] in the `mem_fn` documentation, you need to `#define BOOST_MEM_FN_ENABLE_STDCALL` first.
[#techniques_intrusive]
## Using a shared_ptr to hold a pointer to an object with an embedded reference count

View File

@@ -0,0 +1,228 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_ALLOCATE_LOCAL_SHARED_ARRAY_HPP
#include <boost/smart_ptr/allocate_shared_array.hpp>
#include <boost/smart_ptr/local_shared_ptr.hpp>
namespace boost {
namespace detail {
template<class>
struct lsp_if_array { };
template<class T>
struct lsp_if_array<T[]> {
typedef boost::local_shared_ptr<T[]> type;
};
template<class>
struct lsp_if_size_array { };
template<class T, std::size_t N>
struct lsp_if_size_array<T[N]> {
typedef boost::local_shared_ptr<T[N]> type;
};
class lsp_array_base
: public local_counted_base {
public:
void set(sp_counted_base* base) BOOST_SP_NOEXCEPT {
count_ = shared_count(base);
}
virtual void local_cb_destroy() BOOST_SP_NOEXCEPT {
shared_count().swap(count_);
}
virtual shared_count local_cb_get_shared_count() const BOOST_SP_NOEXCEPT {
return count_;
}
private:
shared_count count_;
};
template<class A>
class lsp_array_state
: public sp_array_state<A> {
public:
template<class U>
lsp_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_array_state<A>(other, size) { }
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
private:
lsp_array_base base_;
};
template<class A, std::size_t N>
class lsp_size_array_state
: public sp_size_array_state<A, N> {
public:
template<class U>
lsp_size_array_state(const U& other, std::size_t size) BOOST_SP_NOEXCEPT
: sp_size_array_state<A, N>(other, size) { }
lsp_array_base& base() BOOST_SP_NOEXCEPT {
return base_;
}
private:
lsp_array_base base_;
};
} /* detail */
template<class T, class A>
inline typename detail::lsp_if_array<T>::type
allocate_local_shared(const A& allocator, std::size_t count)
{
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_array_state<other> state;
typedef detail::sp_array_base<state> base;
std::size_t size = count * detail::sp_array_count<type>::value;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(allocator, size, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
template<class T, class A>
inline typename detail::lsp_if_size_array<T>::type
allocate_local_shared(const A& allocator)
{
enum {
size = detail::sp_array_count<T>::value
};
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_size_array_state<other, size> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(allocator, size, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
template<class T, class A>
inline typename detail::lsp_if_array<T>::type
allocate_local_shared(const A& allocator, std::size_t count,
const typename detail::sp_array_element<T>::type& value)
{
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_array_state<other> state;
typedef detail::sp_array_base<state> base;
std::size_t size = count * detail::sp_array_count<type>::value;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(allocator, size,
reinterpret_cast<const scalar*>(&value),
detail::sp_array_count<type>::value, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
template<class T, class A>
inline typename detail::lsp_if_size_array<T>::type
allocate_local_shared(const A& allocator,
const typename detail::sp_array_element<T>::type& value)
{
enum {
size = detail::sp_array_count<T>::value
};
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_size_array_state<other, size> state;
typedef detail::sp_array_base<state> base;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(allocator, size,
reinterpret_cast<const scalar*>(&value),
detail::sp_array_count<type>::value, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
template<class T, class A>
inline typename detail::lsp_if_array<T>::type
allocate_local_shared_noinit(const A& allocator, std::size_t count)
{
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_array_state<other> state;
typedef detail::sp_array_base<state, false> base;
std::size_t size = count * detail::sp_array_count<type>::value;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(detail::sp_default(), allocator,
size, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
template<class T, class A>
inline typename detail::lsp_if_size_array<T>::type
allocate_local_shared_noinit(const A& allocator)
{
enum {
size = detail::sp_array_count<T>::value
};
typedef typename detail::sp_array_element<T>::type type;
typedef typename detail::sp_array_scalar<T>::type scalar;
typedef typename detail::sp_bind_allocator<A, scalar>::type other;
typedef detail::lsp_size_array_state<other, size> state;
typedef detail::sp_array_base<state, false> base;
detail::sp_array_result<other, base> result(allocator, size);
base* node = result.get();
scalar* start = detail::sp_array_start<base, scalar>(node);
::new(static_cast<void*>(node)) base(detail::sp_default(), allocator,
size, start);
detail::lsp_array_base& local = node->state().base();
local.set(node);
result.release();
return local_shared_ptr<T>(detail::lsp_internal_constructor_tag(),
reinterpret_cast<type*>(start), &local);
}
} /* boost */
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,6 @@
#include <boost/smart_ptr/detail/shared_count.hpp>
#include <boost/config.hpp>
#include <utility>
#include <climits>
namespace boost
{
@@ -37,7 +36,7 @@ private:
private:
// not 'int' or 'unsigned' to avoid aliasing and enable optimizations
enum count_type { min_ = 0, initial_ = 1, max_ = UINT_MAX };
enum count_type { min_ = 0, initial_ = 1, max_ = 2147483647 };
count_type local_use_count_;

View File

@@ -125,6 +125,13 @@ public:
{
}
BOOST_CONSTEXPR explicit shared_count( sp_counted_base * pi ): pi_( pi ) // nothrow
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)
#endif
{
}
template<class Y> explicit shared_count( Y * p ): pi_( 0 )
#if defined(BOOST_SP_ENABLE_DEBUG_HOOKS)
, id_(shared_count_id)

View File

@@ -33,7 +33,7 @@
// BOOST_SMT_PAUSE
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) )
#if defined(_MSC_VER) && _MSC_VER >= 1310 && ( defined(_M_IX86) || defined(_M_X64) ) && !defined(__c2__)
extern "C" void _mm_pause();

View File

@@ -149,7 +149,7 @@ public:
#endif
// internal constructor, used by make_shared
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, T * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
BOOST_CONSTEXPR local_shared_ptr( boost::detail::lsp_internal_constructor_tag, element_type * px_, boost::detail::local_counted_base * pn_ ) BOOST_SP_NOEXCEPT : px( px_ ), pn( pn_ )
{
}

View File

@@ -1,63 +1,67 @@
#ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP_INCLUDED
#define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP_INCLUDED
/*
Copyright 2017 Peter Dimov
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
// make_local_shared_array.hpp
//
// Copyright 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// See http://www.boost.org/libs/smart_ptr/ for documentation.
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
#define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
#include <boost/config.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#include <utility>
#include <cstddef>
#include <boost/smart_ptr/allocate_local_shared_array.hpp>
namespace boost
namespace boost {
template<class T>
inline typename detail::lsp_if_size_array<T>::type
make_local_shared()
{
namespace detail
{
template<class T> struct lsp_if_array
{
};
template<class T> struct lsp_if_array<T[]>
{
typedef boost::local_shared_ptr<T[]> type;
};
template<class T, std::size_t N> struct lsp_if_array<T[N]>
{
typedef boost::local_shared_ptr<T[N]> type;
};
} // namespace detail
template<class T, class... Args> typename boost::detail::lsp_if_array<T>::type make_local_shared( Args&&... args )
{
return boost::make_shared<T>( std::forward<Args>(args)... );
return boost::allocate_local_shared<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>());
}
template<class T, class... Args> typename boost::detail::lsp_if_array<T>::type make_local_shared_noinit( Args&&... args )
template<class T>
inline typename detail::lsp_if_size_array<T>::type
make_local_shared(const typename detail::sp_array_element<T>::type& value)
{
return boost::make_shared_noinit<T>( std::forward<Args>(args)... );
return boost::allocate_local_shared<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>(), value);
}
template<class T, class A, class... Args> typename boost::detail::lsp_if_array<T>::type allocate_local_shared( A const & a, Args&&... args )
template<class T>
inline typename detail::lsp_if_array<T>::type
make_local_shared(std::size_t size)
{
return boost::allocate_shared<T>( a, std::forward<Args>(args)... );
return boost::allocate_local_shared<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>(), size);
}
template<class T, class A, class... Args> typename boost::detail::lsp_if_array<T>::type allocate_local_shared_noinit( A const & a, Args&&... args )
template<class T>
inline typename detail::lsp_if_array<T>::type
make_local_shared(std::size_t size,
const typename detail::sp_array_element<T>::type& value)
{
return boost::allocate_shared_noinit<T>( a, std::forward<Args>(args)... );
return boost::allocate_local_shared<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>(), size, value);
}
} // namespace boost
template<class T>
inline typename detail::lsp_if_size_array<T>::type
make_local_shared_noinit()
{
return allocate_local_shared_noinit<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>());
}
#endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED
template<class T>
inline typename detail::lsp_if_array<T>::type
make_local_shared_noinit(std::size_t size)
{
return allocate_local_shared_noinit<T>(std::allocator<typename
detail::sp_array_scalar<T>::type>(), size);
}
} /* boost */
#endif

View File

@@ -165,7 +165,7 @@ template<class T, class A> typename boost::detail::lsp_if_not_array<T>::type all
A2 a2( a );
typedef boost::detail::lsp_ms_deleter<T, A2> D;
typedef boost::detail::lsp_ms_deleter< T, std::allocator<T> > D;
boost::shared_ptr<T> pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a2 );

View File

@@ -9,7 +9,6 @@
"Glen Fernandes"
],
"description": "Smart pointer class templates.",
"documentation": "smart_ptr.htm",
"std": [
"tr1"
],

261
test/Jamfile Normal file
View File

@@ -0,0 +1,261 @@
# Boost.SmartPtr Library test Jamfile
#
# Copyright (c) 2003-2017 Peter Dimov
# Copyright (c) 2003 Dave Abrahams
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# bring in rules for testing
import testing ;
run smart_ptr_test.cpp ;
run shared_ptr_basic_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
run shared_ptr_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
run weak_ptr_test.cpp ;
run weak_ptr_move_test.cpp ;
run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ;
run get_deleter_test.cpp ;
run intrusive_ptr_test.cpp ;
run intrusive_ptr_move_test.cpp ;
run intrusive_ref_counter_test.cpp ;
run atomic_count_test.cpp ;
run lw_mutex_test.cpp ;
compile-fail shared_ptr_assign_fail.cpp ;
compile-fail shared_ptr_delete_fail.cpp ;
compile-fail shared_ptr_compare_fail.cpp ;
run shared_ptr_alloc2_test.cpp ;
run pointer_cast_test.cpp ;
run cpp11_pointer_cast_test.cpp ;
compile pointer_to_other_test.cpp ;
run auto_ptr_rv_test.cpp ;
run shared_ptr_alias_test.cpp ;
run shared_ptr_rv_test.cpp ;
run shared_ptr_rv_pointer_cast_test.cpp ;
run shared_ptr_move_test.cpp ;
run shared_ptr_alias_move_test.cpp ;
run shared_ptr_reinterpret_pointer_cast_test.cpp ;
compile-fail shared_ptr_pv_fail.cpp ;
run sp_unary_addr_test.cpp ;
compile-fail scoped_ptr_eq_fail.cpp ;
compile-fail scoped_array_eq_fail.cpp ;
run esft_regtest.cpp ;
run yield_k_test.cpp ;
run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ;
run spinlock_test.cpp ;
run spinlock_try_test.cpp ;
run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ;
run spinlock_pool_test.cpp ;
run make_shared_test.cpp ;
run make_shared_move_emulation_test.cpp ;
run make_shared_perfect_forwarding_test.cpp ;
run shared_ptr_convertible_test.cpp ;
run wp_convertible_test.cpp ;
run ip_convertible_test.cpp ;
run allocate_shared_test.cpp ;
run sp_atomic_test.cpp ;
run esft_void_test.cpp ;
run esft_second_ptr_test.cpp ;
run make_shared_esft_test.cpp ;
run allocate_shared_esft_test.cpp ;
run sp_recursive_assign_test.cpp ;
run sp_recursive_assign2_test.cpp ;
run sp_recursive_assign_rv_test.cpp ;
run sp_recursive_assign2_rv_test.cpp ;
compile-fail auto_ptr_lv_fail.cpp ;
run atomic_count_test2.cpp ;
run sp_typeinfo_test.cpp ;
compile make_shared_fp_test.cpp ;
run sp_hash_test.cpp ;
run get_deleter_array_test.cpp ;
run ip_hash_test.cpp ;
run owner_less_test.cpp ;
run sp_unique_ptr_test.cpp ;
run sp_array_test.cpp ;
compile sp_array_cv_test.cpp ;
run sp_convertible_test.cpp ;
run sp_array_n_test.cpp ;
run sp_array_cast_test.cpp ;
run sp_zero_compare_test.cpp ;
run sp_nullptr_test.cpp ;
run sa_nullptr_test.cpp ;
run shared_ptr_alloc3_test.cpp ;
run shared_ptr_alloc11_test.cpp ;
run shared_ptr_alloc_construct11_test.cpp ;
run allocate_shared_alloc11_test.cpp ;
run allocate_shared_construct11_test.cpp ;
run sp_interlocked_test.cpp ;
compile-fail array_fail_spa_sp_c.cpp ;
compile-fail array_fail_sp_spa_c.cpp ;
compile-fail array_fail_spa_spa_c.cpp ;
compile-fail array_fail_spa_wp_c.cpp ;
compile-fail array_fail_sp_wpa_c.cpp ;
compile-fail array_fail_spa_wpa_c.cpp ;
compile-fail array_fail_wpa_wp_c.cpp ;
compile-fail array_fail_wp_wpa_c.cpp ;
compile-fail array_fail_wpa_wpa_c.cpp ;
compile-fail array_fail_ap_spa_c.cpp ;
compile-fail array_fail_upa_sp_c.cpp ;
compile-fail array_fail_up_spa_c.cpp ;
compile-fail array_fail_spa_sp_mc.cpp ;
compile-fail array_fail_sp_spa_mc.cpp ;
compile-fail array_fail_spa_spa_mc.cpp ;
compile-fail array_fail_spa_wp_mc.cpp ;
compile-fail array_fail_sp_wpa_mc.cpp ;
compile-fail array_fail_spa_wpa_mc.cpp ;
compile-fail array_fail_wpa_wp_mc.cpp ;
compile-fail array_fail_wp_wpa_mc.cpp ;
compile-fail array_fail_wpa_wpa_mc.cpp ;
compile-fail array_fail_ap_spa_mc.cpp ;
compile-fail array_fail_upa_sp_mc.cpp ;
compile-fail array_fail_up_spa_mc.cpp ;
compile-fail array_fail_spa_sp_a.cpp ;
compile-fail array_fail_sp_spa_a.cpp ;
compile-fail array_fail_spa_spa_a.cpp ;
compile-fail array_fail_spa_wp_a.cpp ;
compile-fail array_fail_sp_wpa_a.cpp ;
compile-fail array_fail_spa_wpa_a.cpp ;
compile-fail array_fail_wpa_wp_a.cpp ;
compile-fail array_fail_wp_wpa_a.cpp ;
compile-fail array_fail_wpa_wpa_a.cpp ;
compile-fail array_fail_ap_spa_a.cpp ;
compile-fail array_fail_upa_sp_a.cpp ;
compile-fail array_fail_up_spa_a.cpp ;
compile-fail array_fail_spa_sp_ma.cpp ;
compile-fail array_fail_sp_spa_ma.cpp ;
compile-fail array_fail_spa_spa_ma.cpp ;
compile-fail array_fail_spa_wp_ma.cpp ;
compile-fail array_fail_sp_wpa_ma.cpp ;
compile-fail array_fail_spa_wpa_ma.cpp ;
compile-fail array_fail_wpa_wp_ma.cpp ;
compile-fail array_fail_wp_wpa_ma.cpp ;
compile-fail array_fail_wpa_wpa_ma.cpp ;
compile-fail array_fail_ap_spa_ma.cpp ;
compile-fail array_fail_upa_sp_ma.cpp ;
compile-fail array_fail_up_spa_ma.cpp ;
compile-fail array_fail_dereference.cpp ;
compile-fail array_fail_member_access.cpp ;
compile-fail array_fail_array_access.cpp ;
run make_shared_array_test.cpp ;
run make_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run make_shared_array_throws_test.cpp ;
run make_shared_array_esft_test.cpp ;
run make_shared_array_noinit_test.cpp ;
run make_shared_array_value_test.cpp ;
run allocate_shared_array_test.cpp ;
run allocate_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run allocate_shared_array_throws_test.cpp ;
run allocate_shared_array_esft_test.cpp ;
run allocate_shared_array_noinit_test.cpp ;
run allocate_shared_array_value_test.cpp ;
run allocate_shared_array_construct_test.cpp ;
run make_unique_test.cpp ;
run make_unique_args_test.cpp ;
run make_unique_value_test.cpp ;
run make_unique_noinit_test.cpp ;
run make_unique_throws_test.cpp ;
run make_unique_array_test.cpp ;
run make_unique_array_noinit_test.cpp ;
run make_unique_array_throws_test.cpp ;
run shared_from_raw_test.cpp ;
run shared_from_raw_test2.cpp ;
run shared_from_raw_test3.cpp ;
run shared_from_raw_test4.cpp ;
run shared_from_raw_test5.cpp ;
run shared_from_raw_test6.cpp ;
run weak_from_raw_test.cpp ;
run weak_from_raw_test2.cpp ;
run weak_from_raw_test3.cpp ;
run weak_from_raw_test4.cpp ;
run weak_from_raw_test5.cpp ;
compile sp_explicit_inst_test.cpp ;
run weak_from_this_test.cpp ;
run weak_from_this_test2.cpp ;
run sp_bml_unique_ptr_test.cpp ;
run sp_hash_test2.cpp ;
run sp_hash_test3.cpp ;
run pointer_cast_test2.cpp ;
compile-fail pointer_cast_st_fail.cpp ;
compile-fail pointer_cast_st_fail2.cpp ;
compile-fail pointer_cast_st_fail3.cpp ;
compile-fail pointer_cast_co_fail.cpp ;
compile-fail pointer_cast_co_fail2.cpp ;
compile-fail pointer_cast_co_fail3.cpp ;
compile-fail pointer_cast_dy_fail.cpp ;
compile-fail pointer_cast_dy_fail2.cpp ;
compile-fail pointer_cast_dy_fail3.cpp ;
run sp_nothrow_test.cpp ;
compile make_shared_msvc_test.cpp ;
compile lwm_win32_cs_test.cpp ;
run atomic_sp_test.cpp ;
run sp_constexpr_test.cpp ;
run sp_constexpr_test2.cpp ;
run atomic_sp_constexpr_test.cpp ;
run shared_ptr_fn_test.cpp ;
run get_deleter_test2.cpp ;
run get_deleter_test3.cpp ;
run get_deleter_array_test2.cpp ;
run get_deleter_array_test3.cpp ;
run sp_convertible_test2.cpp ;
run local_sp_test.cpp ;
run lsp_array_test.cpp ;
run lsp_array_n_test.cpp ;
run lsp_array_cv_test.cpp ;
run lsp_array_cast_test.cpp ;
run get_local_deleter_test.cpp ;
run get_local_deleter_test2.cpp ;
run get_local_deleter_test3.cpp ;
run get_local_deleter_array_test.cpp ;
run get_local_deleter_array_test2.cpp ;
run make_local_shared_test.cpp ;
run make_local_shared_esft_test.cpp ;
run allocate_local_shared_test.cpp ;
run allocate_local_shared_esft_test.cpp ;
run make_local_shared_array_test.cpp ;
run make_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run make_local_shared_array_throws_test.cpp ;
run make_local_shared_array_esft_test.cpp ;
run make_local_shared_array_noinit_test.cpp ;
run make_local_shared_array_value_test.cpp ;
run allocate_local_shared_array_test.cpp ;
run allocate_local_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ;
run allocate_local_shared_array_throws_test.cpp ;
run allocate_local_shared_array_esft_test.cpp ;
run allocate_local_shared_array_noinit_test.cpp ;
run allocate_local_shared_array_value_test.cpp ;
run allocate_local_shared_array_construct_test.cpp ;
run local_sp_fn_test.cpp ;
run lsp_convertible_test.cpp ;
run lsp_convertible_test2.cpp ;

View File

@@ -1,247 +0,0 @@
# Boost.SmartPtr Library test Jamfile
#
# Copyright (c) 2003-2017 Peter Dimov
# Copyright (c) 2003 Dave Abrahams
#
# Distributed under the Boost Software License, Version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# bring in rules for testing
import testing ;
{
test-suite "smart_ptr"
: [ run smart_ptr_test.cpp ]
[ run shared_ptr_basic_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
[ run shared_ptr_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
[ run weak_ptr_test.cpp ]
[ run weak_ptr_move_test.cpp ]
[ run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
[ run get_deleter_test.cpp ]
[ run intrusive_ptr_test.cpp ]
[ run intrusive_ptr_move_test.cpp ]
[ run intrusive_ref_counter_test.cpp ]
[ run atomic_count_test.cpp ]
[ run lw_mutex_test.cpp ]
[ compile-fail shared_ptr_assign_fail.cpp ]
[ compile-fail shared_ptr_delete_fail.cpp ]
[ compile-fail shared_ptr_compare_fail.cpp ]
[ run shared_ptr_alloc2_test.cpp ]
[ run pointer_cast_test.cpp ]
[ run cpp11_pointer_cast_test.cpp ]
[ compile pointer_to_other_test.cpp ]
[ run auto_ptr_rv_test.cpp ]
[ run shared_ptr_alias_test.cpp ]
[ run shared_ptr_rv_test.cpp ]
[ run shared_ptr_rv_pointer_cast_test.cpp ]
[ run shared_ptr_move_test.cpp ]
[ run shared_ptr_alias_move_test.cpp ]
[ run shared_ptr_reinterpret_pointer_cast_test.cpp ]
[ compile-fail shared_ptr_pv_fail.cpp ]
[ run sp_unary_addr_test.cpp ]
[ compile-fail scoped_ptr_eq_fail.cpp ]
[ compile-fail scoped_array_eq_fail.cpp ]
[ run esft_regtest.cpp ]
[ run yield_k_test.cpp ]
[ run yield_k_test.cpp : : : <threading>multi : yield_k_test.mt ]
[ run spinlock_test.cpp ]
[ run spinlock_try_test.cpp ]
[ run spinlock_try_test.cpp : : : <threading>multi : spinlock_try_test.mt ]
[ run spinlock_pool_test.cpp ]
[ run make_shared_test.cpp ]
[ run make_shared_move_emulation_test.cpp ]
[ run make_shared_perfect_forwarding_test.cpp ]
[ run shared_ptr_convertible_test.cpp ]
[ run wp_convertible_test.cpp ]
[ run ip_convertible_test.cpp ]
[ run allocate_shared_test.cpp ]
[ run sp_atomic_test.cpp ]
[ run esft_void_test.cpp ]
[ run esft_second_ptr_test.cpp ]
[ run make_shared_esft_test.cpp ]
[ run allocate_shared_esft_test.cpp ]
[ run sp_recursive_assign_test.cpp ]
[ run sp_recursive_assign2_test.cpp ]
[ run sp_recursive_assign_rv_test.cpp ]
[ run sp_recursive_assign2_rv_test.cpp ]
[ compile-fail auto_ptr_lv_fail.cpp ]
[ run atomic_count_test2.cpp ]
[ run sp_typeinfo_test.cpp ]
[ compile make_shared_fp_test.cpp ]
[ run sp_hash_test.cpp ]
[ run get_deleter_array_test.cpp ]
[ run ip_hash_test.cpp ]
[ run owner_less_test.cpp ]
[ run sp_unique_ptr_test.cpp ]
[ run sp_array_test.cpp ]
[ compile sp_array_cv_test.cpp ]
[ run sp_convertible_test.cpp ]
[ run sp_array_n_test.cpp ]
[ run sp_array_cast_test.cpp ]
[ run sp_zero_compare_test.cpp ]
[ run sp_nullptr_test.cpp ]
[ run sa_nullptr_test.cpp ]
[ run shared_ptr_alloc3_test.cpp ]
[ run shared_ptr_alloc11_test.cpp ]
[ run shared_ptr_alloc_construct11_test.cpp ]
[ run allocate_shared_alloc11_test.cpp ]
[ run allocate_shared_construct11_test.cpp ]
[ run sp_interlocked_test.cpp ]
[ compile-fail array_fail_spa_sp_c.cpp ]
[ compile-fail array_fail_sp_spa_c.cpp ]
[ compile-fail array_fail_spa_spa_c.cpp ]
[ compile-fail array_fail_spa_wp_c.cpp ]
[ compile-fail array_fail_sp_wpa_c.cpp ]
[ compile-fail array_fail_spa_wpa_c.cpp ]
[ compile-fail array_fail_wpa_wp_c.cpp ]
[ compile-fail array_fail_wp_wpa_c.cpp ]
[ compile-fail array_fail_wpa_wpa_c.cpp ]
[ compile-fail array_fail_ap_spa_c.cpp ]
[ compile-fail array_fail_upa_sp_c.cpp ]
[ compile-fail array_fail_up_spa_c.cpp ]
[ compile-fail array_fail_spa_sp_mc.cpp ]
[ compile-fail array_fail_sp_spa_mc.cpp ]
[ compile-fail array_fail_spa_spa_mc.cpp ]
[ compile-fail array_fail_spa_wp_mc.cpp ]
[ compile-fail array_fail_sp_wpa_mc.cpp ]
[ compile-fail array_fail_spa_wpa_mc.cpp ]
[ compile-fail array_fail_wpa_wp_mc.cpp ]
[ compile-fail array_fail_wp_wpa_mc.cpp ]
[ compile-fail array_fail_wpa_wpa_mc.cpp ]
[ compile-fail array_fail_ap_spa_mc.cpp ]
[ compile-fail array_fail_upa_sp_mc.cpp ]
[ compile-fail array_fail_up_spa_mc.cpp ]
[ compile-fail array_fail_spa_sp_a.cpp ]
[ compile-fail array_fail_sp_spa_a.cpp ]
[ compile-fail array_fail_spa_spa_a.cpp ]
[ compile-fail array_fail_spa_wp_a.cpp ]
[ compile-fail array_fail_sp_wpa_a.cpp ]
[ compile-fail array_fail_spa_wpa_a.cpp ]
[ compile-fail array_fail_wpa_wp_a.cpp ]
[ compile-fail array_fail_wp_wpa_a.cpp ]
[ compile-fail array_fail_wpa_wpa_a.cpp ]
[ compile-fail array_fail_ap_spa_a.cpp ]
[ compile-fail array_fail_upa_sp_a.cpp ]
[ compile-fail array_fail_up_spa_a.cpp ]
[ compile-fail array_fail_spa_sp_ma.cpp ]
[ compile-fail array_fail_sp_spa_ma.cpp ]
[ compile-fail array_fail_spa_spa_ma.cpp ]
[ compile-fail array_fail_spa_wp_ma.cpp ]
[ compile-fail array_fail_sp_wpa_ma.cpp ]
[ compile-fail array_fail_spa_wpa_ma.cpp ]
[ compile-fail array_fail_wpa_wp_ma.cpp ]
[ compile-fail array_fail_wp_wpa_ma.cpp ]
[ compile-fail array_fail_wpa_wpa_ma.cpp ]
[ compile-fail array_fail_ap_spa_ma.cpp ]
[ compile-fail array_fail_upa_sp_ma.cpp ]
[ compile-fail array_fail_up_spa_ma.cpp ]
[ compile-fail array_fail_dereference.cpp ]
[ compile-fail array_fail_member_access.cpp ]
[ compile-fail array_fail_array_access.cpp ]
[ run make_shared_array_test.cpp ]
[ run make_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ]
[ run make_shared_array_throws_test.cpp ]
[ run make_shared_array_esft_test.cpp ]
[ run make_shared_array_noinit_test.cpp ]
[ run make_shared_array_value_test.cpp ]
[ run allocate_shared_array_test.cpp ]
[ run allocate_shared_arrays_test.cpp : : : <toolset>gcc-4.6.3_0x:<cxxflags>-fno-deduce-init-list ]
[ run allocate_shared_array_throws_test.cpp ]
[ run allocate_shared_array_esft_test.cpp ]
[ run allocate_shared_array_noinit_test.cpp ]
[ run allocate_shared_array_value_test.cpp ]
[ run allocate_shared_array_construct_test.cpp ]
[ run make_unique_test.cpp ]
[ run make_unique_args_test.cpp ]
[ run make_unique_value_test.cpp ]
[ run make_unique_noinit_test.cpp ]
[ run make_unique_throws_test.cpp ]
[ run make_unique_array_test.cpp ]
[ run make_unique_array_noinit_test.cpp ]
[ run make_unique_array_throws_test.cpp ]
[ run shared_from_raw_test.cpp ]
[ run shared_from_raw_test2.cpp ]
[ run shared_from_raw_test3.cpp ]
[ run shared_from_raw_test4.cpp ]
[ run shared_from_raw_test5.cpp ]
[ run shared_from_raw_test6.cpp ]
[ run weak_from_raw_test.cpp ]
[ run weak_from_raw_test2.cpp ]
[ run weak_from_raw_test3.cpp ]
[ run weak_from_raw_test4.cpp ]
[ run weak_from_raw_test5.cpp ]
[ compile sp_explicit_inst_test.cpp ]
[ run weak_from_this_test.cpp ]
[ run weak_from_this_test2.cpp ]
[ run sp_bml_unique_ptr_test.cpp ]
[ run sp_hash_test2.cpp ]
[ run sp_hash_test3.cpp ]
[ run pointer_cast_test2.cpp ]
[ compile-fail pointer_cast_st_fail.cpp ]
[ compile-fail pointer_cast_st_fail2.cpp ]
[ compile-fail pointer_cast_st_fail3.cpp ]
[ compile-fail pointer_cast_co_fail.cpp ]
[ compile-fail pointer_cast_co_fail2.cpp ]
[ compile-fail pointer_cast_co_fail3.cpp ]
[ compile-fail pointer_cast_dy_fail.cpp ]
[ compile-fail pointer_cast_dy_fail2.cpp ]
[ compile-fail pointer_cast_dy_fail3.cpp ]
[ run sp_nothrow_test.cpp ]
[ compile make_shared_msvc_test.cpp ]
[ compile lwm_win32_cs_test.cpp ]
[ run atomic_sp_test.cpp ]
[ run sp_constexpr_test.cpp ]
[ run sp_constexpr_test2.cpp ]
[ run atomic_sp_constexpr_test.cpp ]
[ run shared_ptr_fn_test.cpp ]
[ run get_deleter_test2.cpp ]
[ run get_deleter_test3.cpp ]
[ run get_deleter_array_test2.cpp ]
[ run get_deleter_array_test3.cpp ]
[ run local_sp_test.cpp ]
[ run lsp_array_test.cpp ]
[ run lsp_array_n_test.cpp ]
[ run lsp_array_cv_test.cpp ]
[ run lsp_array_cast_test.cpp ]
[ run get_local_deleter_test.cpp ]
[ run get_local_deleter_test2.cpp ]
[ run get_local_deleter_test3.cpp ]
[ run get_local_deleter_array_test.cpp ]
[ run get_local_deleter_array_test2.cpp ]
[ run make_local_shared_test.cpp ]
[ run make_local_shared_esft_test.cpp ]
[ run allocate_local_shared_test.cpp ]
[ run allocate_local_shared_esft_test.cpp ]
[ run local_sp_fn_test.cpp ]
;
}

View File

@@ -0,0 +1,165 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
struct allow { };
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
template<class U>
void construct(U* ptr) {
::new(static_cast<void*>(ptr)) U(allow());
}
template<class U>
void destroy(U* ptr) {
ptr->~U();
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
class type {
public:
static unsigned instances;
explicit type(allow) {
++instances;
}
~type() {
--instances;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::instances = 0;
int main()
{
{
boost::local_shared_ptr<type[]> result =
boost::allocate_local_shared<type[]>(creator<type>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[3]> result =
boost::allocate_local_shared<type[3]>(creator<type>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[][2]> result =
boost::allocate_local_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[2][2]> result =
boost::allocate_local_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[]> result =
boost::allocate_local_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[3]> result =
boost::allocate_local_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[][2]> result =
boost::allocate_local_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[2][2]> result =
boost::allocate_local_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,103 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
class type
: public boost::enable_shared_from_this<type> {
public:
static unsigned instances;
type() {
++instances;
}
~type() {
--instances;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::instances = 0;
int main()
{
BOOST_TEST(type::instances == 0);
{
boost::local_shared_ptr<type[]> result =
boost::allocate_local_shared<type[]>(creator<type>(), 3);
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
}
}
BOOST_TEST(type::instances == 0);
{
boost::local_shared_ptr<type[]> result =
boost::allocate_local_shared_noinit<type[]>(creator<>(), 3);
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
}
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,254 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
class type {
public:
static unsigned instances;
type()
: value_(0.0) {
++instances;
}
~type() {
--instances;
}
void set(long double value) {
value_ = value;
}
long double get() const {
return value_;
}
private:
type(const type&);
type& operator=(const type&);
long double value_;
};
unsigned type::instances = 0;
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::allocate_local_shared_noinit<int[]>(creator<int>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[3]> result =
boost::allocate_local_shared_noinit<int[3]>(creator<int>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[][2]> result =
boost::allocate_local_shared_noinit<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::allocate_local_shared_noinit<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[]> result =
boost::allocate_local_shared_noinit<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[3]> result =
boost::allocate_local_shared_noinit<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::allocate_local_shared_noinit<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::allocate_local_shared_noinit<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<type[]> result =
boost::allocate_local_shared_noinit<type[]>(creator<type>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[3]> result =
boost::allocate_local_shared_noinit<type[3]>(creator<type>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[][2]> result =
boost::allocate_local_shared_noinit<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[2][2]> result =
boost::allocate_local_shared_noinit<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[2][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[]> result =
boost::allocate_local_shared_noinit<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[3]> result =
boost::allocate_local_shared_noinit<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[3]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[][2]> result =
boost::allocate_local_shared_noinit<const
type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[2][2]> result =
boost::allocate_local_shared_noinit<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[2][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,275 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
class type {
public:
static unsigned instances;
type()
: value_(0.0) {
++instances;
}
~type() {
--instances;
}
void set(long double value) {
value_ = value;
}
long double get() const {
return value_;
}
private:
type(const type&);
type& operator=(const type&);
long double value_;
};
unsigned type::instances = 0;
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::allocate_local_shared<int[]>(creator<int>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<int[3]> result =
boost::allocate_local_shared<int[3]>(creator<int>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<int[][2]> result =
boost::allocate_local_shared<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::allocate_local_shared<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<const int[]> result =
boost::allocate_local_shared<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<const int[3]> result =
boost::allocate_local_shared<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::allocate_local_shared<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::allocate_local_shared<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<type[]> result =
boost::allocate_local_shared<type[]>(creator<type>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> w1 = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[3]> result =
boost::allocate_local_shared<type[3]>(creator<type>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> w1 = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[][2]> result =
boost::allocate_local_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[2][2]> result =
boost::allocate_local_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[]> result =
boost::allocate_local_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[3]> result =
boost::allocate_local_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[][2]> result =
boost::allocate_local_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[2][2]> result =
boost::allocate_local_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,130 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
class type {
public:
static unsigned instances;
type() {
if (instances == 5) {
throw true;
}
++instances;
}
~type() {
--instances;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::instances = 0;
int main()
{
try {
boost::allocate_local_shared<type[]>(creator<type>(), 6);
BOOST_ERROR("allocate_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared<type[][2]>(creator<type>(), 3);
BOOST_ERROR("allocate_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared<type[6]>(creator<>());
BOOST_ERROR("allocate_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared<type[3][2]>(creator<>());
BOOST_ERROR("allocate_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared_noinit<type[]>(creator<>(), 6);
BOOST_ERROR("allocate_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared_noinit<type[][2]>(creator<>(), 3);
BOOST_ERROR("allocate_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared_noinit<type[6]>(creator<>());
BOOST_ERROR("allocate_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_local_shared_noinit<type[3][2]>(creator<>());
BOOST_ERROR("allocate_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,92 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::allocate_local_shared<int[]>(creator<int>(), 4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<int[4]> result =
boost::allocate_local_shared<int[4]>(creator<int>(), 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<const int[]> result =
boost::allocate_local_shared<const int[]>(creator<>(), 4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<const int[4]> result =
boost::allocate_local_shared<const int[4]>(creator<>(), 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,93 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
template<class T = void>
struct creator {
typedef T value_type;
template<class U>
struct rebind {
typedef creator<U> other;
};
creator() { }
template<class U>
creator(const creator<U>&) { }
T* allocate(std::size_t size) {
return static_cast<T*>(::operator new(sizeof(T) * size));
}
void deallocate(T* ptr, std::size_t) {
::operator delete(ptr);
}
};
template<class T, class U>
inline bool
operator==(const creator<T>&, const creator<U>&)
{
return true;
}
template<class T, class U>
inline bool
operator!=(const creator<T>&, const creator<U>&)
{
return false;
}
int main()
{
{
boost::local_shared_ptr<int[][2]> result =
boost::allocate_local_shared<int[][2]>(creator<int>(), 2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::allocate_local_shared<int[2][2]>(creator<int>(), {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::allocate_local_shared<const int[][2]>(creator<>(), 2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::allocate_local_shared<const int[2][2]>(creator<>(), {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -5,13 +5,14 @@ Copyright 2012-2015 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
struct allow { };
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -100,7 +101,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared<type[][2]>(creator<type>(), 2);
boost::allocate_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@@ -109,7 +110,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared<type[2][2]>(creator<type>());
boost::allocate_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@@ -118,7 +119,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared<const type[]>(creator<type>(), 3);
boost::allocate_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
@@ -127,7 +128,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared<const type[3]>(creator<type>());
boost::allocate_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
@@ -136,7 +137,7 @@ int main()
}
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
boost::allocate_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@@ -145,7 +146,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared<const type[2][2]>(creator<type>());
boost::allocate_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);

View File

@@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -82,7 +82,7 @@ int main()
BOOST_TEST(type::instances == 0);
{
boost::shared_ptr<type[]> result =
boost::allocate_shared_noinit<type[]>(creator<type>(), 3);
boost::allocate_shared_noinit<type[]>(creator<>(), 3);
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");

View File

@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -98,7 +98,7 @@ int main()
}
{
boost::shared_ptr<int[][2]> result =
boost::allocate_shared_noinit<int[][2]>(creator<int>(), 2);
boost::allocate_shared_noinit<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -106,7 +106,7 @@ int main()
}
{
boost::shared_ptr<int[2][2]> result =
boost::allocate_shared_noinit<int[2][2]>(creator<int>());
boost::allocate_shared_noinit<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -114,7 +114,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared_noinit<const int[]>(creator<int>(), 3);
boost::allocate_shared_noinit<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -122,7 +122,7 @@ int main()
}
{
boost::shared_ptr<const int[3]> result =
boost::allocate_shared_noinit<const int[3]>(creator<int>());
boost::allocate_shared_noinit<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -130,7 +130,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared_noinit<const int[][2]>(creator<int>(), 2);
boost::allocate_shared_noinit<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -138,7 +138,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared_noinit<const int[2][2]>(creator<int>());
boost::allocate_shared_noinit<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -170,7 +170,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 2);
boost::allocate_shared_noinit<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -182,7 +182,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared_noinit<type[2][2]>(creator<type>());
boost::allocate_shared_noinit<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -194,7 +194,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared_noinit<const type[]>(creator<type>(), 3);
boost::allocate_shared_noinit<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -206,7 +206,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared_noinit<const type[3]>(creator<type>());
boost::allocate_shared_noinit<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -219,7 +219,7 @@ int main()
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared_noinit<const
type[][2]>(creator<type>(), 2);
type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -231,7 +231,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared_noinit<const type[2][2]>(creator<type>());
boost::allocate_shared_noinit<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),

View File

@@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -104,7 +104,7 @@ int main()
}
{
boost::shared_ptr<int[][2]> result =
boost::allocate_shared<int[][2]>(creator<int>(), 2);
boost::allocate_shared<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -116,7 +116,7 @@ int main()
}
{
boost::shared_ptr<int[2][2]> result =
boost::allocate_shared<int[2][2]>(creator<int>());
boost::allocate_shared<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -128,7 +128,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared<const int[]>(creator<int>(), 3);
boost::allocate_shared<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -139,7 +139,7 @@ int main()
}
{
boost::shared_ptr<const int[3]> result =
boost::allocate_shared<const int[3]>(creator<int>());
boost::allocate_shared<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -150,7 +150,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared<const int[][2]>(creator<int>(), 2);
boost::allocate_shared<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -162,7 +162,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared<const int[2][2]>(creator<int>());
boost::allocate_shared<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -198,7 +198,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared<type[][2]>(creator<type>(), 2);
boost::allocate_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -209,7 +209,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared<type[2][2]>(creator<type>());
boost::allocate_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -220,7 +220,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared<const type[]>(creator<type>(), 3);
boost::allocate_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -231,7 +231,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared<const type[3]>(creator<type>());
boost::allocate_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -242,7 +242,7 @@ int main()
}
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
boost::allocate_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@@ -253,7 +253,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared<const type[2][2]>(creator<type>());
boost::allocate_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),

View File

@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -82,37 +82,37 @@ int main()
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared<type[6]>(creator<type>());
boost::allocate_shared<type[6]>(creator<>());
BOOST_ERROR("allocate_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared<type[3][2]>(creator<type>());
boost::allocate_shared<type[3][2]>(creator<>());
BOOST_ERROR("allocate_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[]>(creator<type>(), 6);
boost::allocate_shared_noinit<type[]>(creator<>(), 6);
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 3);
boost::allocate_shared_noinit<type[][2]>(creator<>(), 3);
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[6]>(creator<type>());
boost::allocate_shared_noinit<type[6]>(creator<>());
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[3][2]>(creator<type>());
boost::allocate_shared_noinit<type[3][2]>(creator<>());
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);

View File

@@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -65,7 +65,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared<const int[]>(creator<int>(), 4, 1);
boost::allocate_shared<const int[]>(creator<>(), 4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
@@ -73,7 +73,7 @@ int main()
}
{
boost::shared_ptr<const int[4]> result =
boost::allocate_shared<const int[4]>(creator<int>(), 1);
boost::allocate_shared<const int[4]>(creator<>(), 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);

View File

@@ -5,11 +5,12 @@ Copyright 2012-2015 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@@ -66,7 +67,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared<const int[][2]>(creator<int>(), 2, {0, 1});
boost::allocate_shared<const int[][2]>(creator<>(), 2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
@@ -74,7 +75,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared<const int[2][2]>(creator<int>(), {0, 1});
boost::allocate_shared<const int[2][2]>(creator<>(), {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);

View File

@@ -0,0 +1,108 @@
#include <boost/config.hpp>
// lsp_convertible_test.cpp
//
// Copyright 2012, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_convertible.hpp>
//
class X;
class B
{
};
class D: public B
{
};
using boost::is_convertible;
#define TEST_CV_TRUE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
#define TEST_CV_FALSE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
using boost::local_shared_ptr;
using boost::shared_ptr;
using boost::weak_ptr;
#define TEST_CV_TRUE( T, U ) \
TEST_CV_TRUE_( local_shared_ptr, T, local_shared_ptr, U ) \
TEST_CV_TRUE_( shared_ptr, T, local_shared_ptr, U )
#define TEST_CV_FALSE( T, U ) \
TEST_CV_FALSE_( local_shared_ptr, T, local_shared_ptr, U ) \
TEST_CV_FALSE_( shared_ptr, T, local_shared_ptr, U )
int main()
{
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
TEST_CV_TRUE( X, X )
TEST_CV_TRUE( X, void )
TEST_CV_FALSE( void, X )
TEST_CV_TRUE( D, B )
TEST_CV_FALSE( B, D )
TEST_CV_TRUE( X[], X[] )
TEST_CV_FALSE( D[], B[] )
TEST_CV_TRUE( X[3], X[3] )
TEST_CV_FALSE( X[3], X[4] )
TEST_CV_FALSE( D[3], B[3] )
TEST_CV_TRUE( X[3], X[] )
TEST_CV_FALSE( X[], X[3] )
TEST_CV_TRUE( X[], void )
TEST_CV_FALSE( void, X[] )
TEST_CV_TRUE( X[3], void )
TEST_CV_FALSE( void, X[3] )
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,108 @@
#include <boost/config.hpp>
// lsp_convertible_test.cpp
//
// Copyright 2012, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/smart_ptr/local_shared_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_convertible.hpp>
//
class X;
class B
{
};
class D: public B
{
};
using boost::is_convertible;
#define TEST_CV_TRUE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
#define TEST_CV_FALSE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
using boost::local_shared_ptr;
using boost::shared_ptr;
using boost::weak_ptr;
#define TEST_CV_TRUE( T, U ) \
TEST_CV_TRUE_( local_shared_ptr, T, shared_ptr, U ) \
TEST_CV_TRUE_( local_shared_ptr, T, weak_ptr, U )
#define TEST_CV_FALSE( T, U ) \
TEST_CV_FALSE_( local_shared_ptr, T, shared_ptr, U ) \
TEST_CV_FALSE_( local_shared_ptr, T, weak_ptr, U )
int main()
{
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && !defined(BOOST_NO_CXX11_FUNCTION_TEMPLATE_DEFAULT_ARGS)
TEST_CV_TRUE( X, X )
TEST_CV_TRUE( X, void )
TEST_CV_FALSE( void, X )
TEST_CV_TRUE( D, B )
TEST_CV_FALSE( B, D )
TEST_CV_TRUE( X[], X[] )
TEST_CV_FALSE( D[], B[] )
TEST_CV_TRUE( X[3], X[3] )
TEST_CV_FALSE( X[3], X[4] )
TEST_CV_FALSE( D[3], B[3] )
TEST_CV_TRUE( X[3], X[] )
TEST_CV_FALSE( X[], X[3] )
TEST_CV_TRUE( X[], void )
TEST_CV_FALSE( void, X[] )
TEST_CV_TRUE( X[3], void )
TEST_CV_FALSE( void, X[3] )
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,66 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
class type
: public boost::enable_shared_from_this<type> {
public:
static unsigned instances;
type() {
++instances;
}
~type() {
--instances;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::instances = 0;
int main()
{
BOOST_TEST(type::instances == 0);
{
boost::local_shared_ptr<type[]> result =
boost::make_local_shared<type[]>(3);
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
}
}
BOOST_TEST(type::instances == 0);
{
boost::local_shared_ptr<type[3]> result =
boost::make_local_shared_noinit<type[3]>();
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
} catch (...) {
BOOST_TEST(type::instances == 3);
}
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,216 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
class type {
public:
static unsigned instances;
type()
: value_(0.0) {
++instances;
}
~type() {
--instances;
}
void set(long double value) {
value_ = value;
}
long double get() const {
return value_;
}
private:
type(const type&);
type& operator=(const type&);
long double value_;
};
unsigned type::instances = 0;
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::make_local_shared_noinit<int[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[3]> result =
boost::make_local_shared_noinit<int[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[][2]> result =
boost::make_local_shared_noinit<int[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::make_local_shared_noinit<int[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[]> result =
boost::make_local_shared_noinit<const int[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[3]> result =
boost::make_local_shared_noinit<const int[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::make_local_shared_noinit<const int[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::make_local_shared_noinit<const int[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
}
{
boost::local_shared_ptr<type[]> result =
boost::make_local_shared_noinit<type[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[3]> result =
boost::make_local_shared_noinit<type[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[][2]> result =
boost::make_local_shared_noinit<type[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[2][2]> result =
boost::make_local_shared_noinit<type[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<type[2][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[]> result =
boost::make_local_shared_noinit<const type[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[3]> result =
boost::make_local_shared_noinit<const type[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<const type[3]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[][2]> result =
boost::make_local_shared_noinit<const type[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[2][2]> result =
boost::make_local_shared_noinit<const type[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
boost::weak_ptr<const type[2][2]> other = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,238 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/align/is_aligned.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
class type {
public:
static unsigned instances;
type()
: value_(0.0) {
++instances;
}
~type() {
--instances;
}
void set(long double value) {
value_ = value;
}
long double get() const {
return value_;
}
private:
type(const type&);
type& operator=(const type&);
long double value_;
};
unsigned type::instances = 0;
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::make_local_shared<int[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<int[3]> result =
boost::make_local_shared<int[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<int[][2]> result =
boost::make_local_shared<int[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::make_local_shared<int[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<const int[]> result =
boost::make_local_shared<const int[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<const int[3]> result =
boost::make_local_shared<const int[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0] == 0);
BOOST_TEST(result[1] == 0);
BOOST_TEST(result[2] == 0);
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::make_local_shared<const int[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::make_local_shared<const int[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<int>::value));
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 0);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 0);
}
{
boost::local_shared_ptr<type[]> result =
boost::make_local_shared<type[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[]> w1 = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[3]> result =
boost::make_local_shared<type[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
boost::weak_ptr<type[3]> w1 = result;
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[][2]> result =
boost::make_local_shared<type[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<type[2][2]> result =
boost::make_local_shared<type[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[]> result =
boost::make_local_shared<const type[]>(3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[3]> result =
boost::make_local_shared<const type[3]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 3);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[][2]> result =
boost::make_local_shared<const type[][2]>(2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
{
boost::local_shared_ptr<const type[2][2]> result =
boost::make_local_shared<const type[2][2]>();
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.local_use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
boost::alignment_of<type>::value));
BOOST_TEST(type::instances == 4);
result.reset();
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,93 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/detail/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
class type {
public:
static unsigned instances;
type() {
if (instances == 5) {
throw true;
}
++instances;
}
~type() {
--instances;
}
private:
type(const type&);
type& operator=(const type&);
};
unsigned type::instances = 0;
int main()
{
try {
boost::make_local_shared<type[]>(6);
BOOST_ERROR("make_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared<type[][2]>(3);
BOOST_ERROR("make_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared<type[6]>();
BOOST_ERROR("make_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared<type[3][2]>();
BOOST_ERROR("make_local_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared_noinit<type[]>(6);
BOOST_ERROR("make_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared_noinit<type[][2]>(3);
BOOST_ERROR("make_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared_noinit<type[6]>();
BOOST_ERROR("make_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::make_local_shared_noinit<type[3][2]>();
BOOST_ERROR("make_local_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,55 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/detail/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
int main()
{
{
boost::local_shared_ptr<int[]> result =
boost::make_local_shared<int[]>(4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<int[4]> result =
boost::make_local_shared<int[4]>(1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<const int[]> result =
boost::make_local_shared<const int[]>(4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
{
boost::local_shared_ptr<const int[4]> result =
boost::make_local_shared<const int[4]>(1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
BOOST_TEST(result[3] == 1);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -0,0 +1,56 @@
/*
Copyright 2017 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \
!defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_local_shared.hpp>
int main()
{
{
boost::local_shared_ptr<int[][2]> result =
boost::make_local_shared<int[][2]>(2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<int[2][2]> result =
boost::make_local_shared<int[2][2]>({0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<const int[][2]> result =
boost::make_local_shared<const int[][2]>(2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
{
boost::local_shared_ptr<const int[2][2]> result =
boost::make_local_shared<const int[2][2]>({0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
BOOST_TEST(result[1][1] == 1);
}
return boost::report_errors();
}
#else
int main()
{
return 0;
}
#endif

View File

@@ -51,6 +51,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >();
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -73,6 +74,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared_noinit< X >();
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -95,6 +97,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -117,6 +120,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -139,6 +143,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -161,6 +166,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -183,6 +189,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -205,6 +212,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -227,6 +235,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -249,6 +258,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -271,6 +281,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_local_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try

View File

@@ -62,12 +62,20 @@ public:
int X::instances = 0;
template<class T> static long use_count( boost::local_shared_ptr<T> const & p )
{
return boost::shared_ptr<T>( p ).use_count() - 1;
}
int main()
{
{
boost::local_shared_ptr< int > pi = boost::make_local_shared< int >();
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( *pi == 0 );
}
@@ -81,6 +89,9 @@ int main()
boost::local_shared_ptr< int > pi = boost::make_local_shared< int >( 5 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( *pi == 5 );
}
@@ -92,6 +103,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 0 );
pi.reset();
@@ -105,6 +118,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 0 );
pi.reset();
@@ -118,6 +133,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1 );
pi.reset();
@@ -131,6 +148,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2 );
pi.reset();
@@ -144,6 +163,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3 );
pi.reset();
@@ -157,6 +178,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4 );
pi.reset();
@@ -170,6 +193,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5 );
pi.reset();
@@ -183,6 +208,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
pi.reset();
@@ -196,6 +223,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
pi.reset();
@@ -209,6 +238,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
pi.reset();
@@ -222,6 +253,8 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.local_use_count() == 1 );
BOOST_TEST( use_count( pi ) == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
pi.reset();

View File

@@ -5,10 +5,11 @@ Copyright 2012-2015 Glen Joseph Fernandes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
*/
#include <boost/config.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
int main()
{
{

View File

@@ -41,6 +41,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >();
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -63,6 +64,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared_noinit< X >();
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -85,6 +87,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -107,6 +110,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -129,6 +133,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -151,6 +156,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -173,6 +179,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -195,6 +202,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -217,6 +225,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -239,6 +248,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try
@@ -261,6 +271,7 @@ int main()
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1, 2, 3, 4, 5, 6, 7, 8, 9 );
BOOST_TEST( px.use_count() == 1 );
BOOST_TEST( X::instances == 1 );
try

View File

@@ -58,6 +58,8 @@ int main()
boost::shared_ptr< int > pi = boost::make_shared< int >();
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( *pi == 0 );
}
@@ -65,12 +67,15 @@ int main()
boost::shared_ptr< int > pi = boost::make_shared_noinit< int >();
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
}
{
boost::shared_ptr< int > pi = boost::make_shared< int >( 5 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( *pi == 5 );
}
@@ -82,6 +87,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 0 );
pi.reset();
@@ -95,6 +101,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 0 );
pi.reset();
@@ -108,6 +115,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1 );
pi.reset();
@@ -121,6 +129,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2 );
pi.reset();
@@ -134,6 +143,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3 );
pi.reset();
@@ -147,6 +157,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4 );
pi.reset();
@@ -160,6 +171,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5 );
pi.reset();
@@ -173,6 +185,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6 );
pi.reset();
@@ -186,6 +199,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7 );
pi.reset();
@@ -199,6 +213,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8 );
pi.reset();
@@ -212,6 +227,7 @@ int main()
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi.use_count() == 1 );
BOOST_TEST( pi->v == 1+2+3+4+5+6+7+8+9 );
pi.reset();

View File

@@ -14,7 +14,7 @@ struct counters {
unsigned construct;
};
template<class T>
template<class T = void>
class creator {
public:
typedef T value_type;
@@ -101,7 +101,7 @@ int main()
{
counters state = { };
boost::shared_ptr<int[]> pointer =
boost::allocate_shared<int[]>(creator<int>(&state), 5);
boost::allocate_shared<int[]>(creator<>(&state), 5);
BOOST_TEST(state.allocate == 1);
BOOST_TEST(state.construct == 5);
pointer.reset();
@@ -111,7 +111,7 @@ int main()
{
counters state = { };
boost::shared_ptr<int[5]> pointer =
boost::allocate_shared<int[5]>(creator<int>(&state));
boost::allocate_shared<int[5]>(creator<>(&state));
BOOST_TEST(state.allocate == 1);
BOOST_TEST(state.construct == 5);
pointer.reset();

View File

@@ -0,0 +1,108 @@
#include <boost/config.hpp>
// sp_convertible_test2.cpp
//
// Copyright 2012, 2017 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_convertible.hpp>
//
class X;
class B
{
};
class D: public B
{
};
using boost::is_convertible;
#define TEST_CV_TRUE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == true )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == true ));
#define TEST_CV_FALSE_( S1, T, S2, U ) \
BOOST_TEST(( is_convertible< S1<T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<volatile T>, S2<const volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<volatile U> >::value == false )); \
BOOST_TEST(( is_convertible< S1<const volatile T>, S2<const volatile U> >::value == false ));
using boost::shared_ptr;
using boost::weak_ptr;
#define TEST_CV_TRUE( T, U ) \
TEST_CV_TRUE_( shared_ptr, T, shared_ptr, U ) \
TEST_CV_TRUE_( shared_ptr, T, weak_ptr, U ) \
TEST_CV_TRUE_( weak_ptr, T, weak_ptr, U )
#define TEST_CV_FALSE( T, U ) \
TEST_CV_FALSE_( shared_ptr, T, shared_ptr, U ) \
TEST_CV_FALSE_( shared_ptr, T, weak_ptr, U ) \
TEST_CV_FALSE_( weak_ptr, T, weak_ptr, U )
int main()
{
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
TEST_CV_TRUE( X, X )
TEST_CV_TRUE( X, void )
TEST_CV_FALSE( void, X )
TEST_CV_TRUE( D, B )
TEST_CV_FALSE( B, D )
TEST_CV_TRUE( X[], X[] )
TEST_CV_FALSE( D[], B[] )
TEST_CV_TRUE( X[3], X[3] )
TEST_CV_FALSE( X[3], X[4] )
TEST_CV_FALSE( D[3], B[3] )
TEST_CV_TRUE( X[3], X[] )
TEST_CV_FALSE( X[], X[3] )
TEST_CV_TRUE( X[], void )
TEST_CV_FALSE( void, X[] )
TEST_CV_TRUE( X[3], void )
TEST_CV_FALSE( void, X[3] )
#endif
return boost::report_errors();
}