forked from boostorg/smart_ptr
Cosmetic changes in make_shared and make_unique
This commit is contained in:
@ -26,7 +26,7 @@ namespace boost {
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(allocator, size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
boost::detail::as_init(allocator, p2, n1);
|
||||
#else
|
||||
@ -53,7 +53,7 @@ namespace boost {
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(allocator, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
boost::detail::as_init(allocator, p2, N);
|
||||
#else
|
||||
@ -84,7 +84,7 @@ namespace boost {
|
||||
T3* p3 = reinterpret_cast<T3*>(&value);
|
||||
D1 d1;
|
||||
A1 a1(allocator, size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
boost::detail::as_init<T2, A, M>(allocator, p2, n1, p3);
|
||||
#else
|
||||
@ -115,7 +115,7 @@ namespace boost {
|
||||
T3* p3 = reinterpret_cast<T3*>(&value);
|
||||
D1 d1;
|
||||
A1 a1(allocator, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||
boost::detail::as_init<T2, A, M>(allocator, p2, N, p3);
|
||||
#else
|
||||
@ -137,10 +137,10 @@ namespace boost {
|
||||
typedef boost::detail::ms_noop D1;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(allocator, size, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
boost::detail::ms_noinit(p2, n1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(p2);
|
||||
@ -163,7 +163,7 @@ namespace boost {
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(allocator, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
boost::detail::ms_noinit(p2, N);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(p2);
|
||||
|
@ -13,10 +13,10 @@
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct up_if_array;
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct up_if_array<T[]> {
|
||||
typedef std::unique_ptr<T[]> type;
|
||||
};
|
||||
|
@ -13,16 +13,16 @@
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct up_if_not_array {
|
||||
typedef std::unique_ptr<T> type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct up_if_not_array<T[]> {
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
template<class T, std::size_t N>
|
||||
struct up_if_not_array<T[N]> {
|
||||
};
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace boost {
|
||||
typedef boost::detail::ms_init_tag R1;
|
||||
typedef boost::detail::ms_allocator<T, R1> A1;
|
||||
typedef boost::detail::ms_noop D1;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
@ -50,10 +50,10 @@ namespace boost {
|
||||
D1 d1;
|
||||
A1 a1(&p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
boost::detail::ms_init(p2, N);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ namespace boost {
|
||||
enum {
|
||||
M = boost::detail::array_total<T1>::size,
|
||||
N = boost::detail::array_total<T>::size
|
||||
};
|
||||
};
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
T3* p3 = reinterpret_cast<T3*>(&value);
|
||||
@ -118,16 +118,16 @@ namespace boost {
|
||||
typedef boost::detail::ms_noinit_tag R1;
|
||||
typedef boost::detail::ms_allocator<T, R1> A1;
|
||||
typedef boost::detail::ms_noop D1;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
std::size_t n1 = size * boost::detail::array_total<T1>::size;
|
||||
T1* p1 = 0;
|
||||
T2* p2 = 0;
|
||||
D1 d1;
|
||||
A1 a1(n1, &p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
boost::detail::ms_noinit(p2, n1);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
|
||||
@ -147,10 +147,10 @@ namespace boost {
|
||||
D1 d1;
|
||||
A1 a1(&p2);
|
||||
shared_ptr<T> s1(p1, d1, a1);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
boost::detail::ms_noinit(p2, N);
|
||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||
a2->set(p2);
|
||||
p1 = reinterpret_cast<T1*>(p2);
|
||||
return shared_ptr<T>(s1, p1);
|
||||
}
|
||||
}
|
||||
|
@ -13,14 +13,14 @@
|
||||
#include <boost/smart_ptr/detail/array_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
template<typename T>
|
||||
template<class T>
|
||||
inline typename boost::detail::up_if_array<T>::type
|
||||
make_unique(std::size_t size) {
|
||||
typedef typename boost::detail::array_inner<T>::type U;
|
||||
return std::unique_ptr<T>(new U[size]());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
inline typename boost::detail::up_if_array<T>::type
|
||||
make_unique_noinit(std::size_t size) {
|
||||
typedef typename boost::detail::array_inner<T>::type U;
|
||||
|
@ -14,27 +14,27 @@
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
template<typename T>
|
||||
template<class T>
|
||||
inline typename boost::detail::up_if_not_array<T>::type
|
||||
make_unique() {
|
||||
return std::unique_ptr<T>(new T());
|
||||
}
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
template<typename T, typename... Args>
|
||||
template<class T, class... Args>
|
||||
inline typename boost::detail::up_if_not_array<T>::type
|
||||
make_unique(Args&&... args) {
|
||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
inline typename boost::detail::up_if_not_array<T>::type
|
||||
make_unique(T&& value) {
|
||||
return std::unique_ptr<T>(new T(std::move(value)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
inline typename boost::detail::up_if_not_array<T>::type
|
||||
make_unique_noinit() {
|
||||
return std::unique_ptr<T>(new T);
|
||||
|
Reference in New Issue
Block a user