forked from boostorg/smart_ptr
Cosmetic changes in make_shared and make_unique
This commit is contained in:
@@ -13,10 +13,10 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<class T>
|
||||||
struct up_if_array;
|
struct up_if_array;
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
struct up_if_array<T[]> {
|
struct up_if_array<T[]> {
|
||||||
typedef std::unique_ptr<T[]> type;
|
typedef std::unique_ptr<T[]> type;
|
||||||
};
|
};
|
||||||
|
@@ -13,16 +13,16 @@
|
|||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<class T>
|
||||||
struct up_if_not_array {
|
struct up_if_not_array {
|
||||||
typedef std::unique_ptr<T> type;
|
typedef std::unique_ptr<T> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
struct up_if_not_array<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]> {
|
struct up_if_not_array<T[N]> {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -50,10 +50,10 @@ namespace boost {
|
|||||||
D1 d1;
|
D1 d1;
|
||||||
A1 a1(&p2);
|
A1 a1(&p2);
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
|
||||||
boost::detail::ms_init(p2, N);
|
boost::detail::ms_init(p2, N);
|
||||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||||
a2->set(p2);
|
a2->set(p2);
|
||||||
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
return shared_ptr<T>(s1, p1);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,10 +124,10 @@ namespace boost {
|
|||||||
D1 d1;
|
D1 d1;
|
||||||
A1 a1(n1, &p2);
|
A1 a1(n1, &p2);
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
|
||||||
boost::detail::ms_noinit(p2, n1);
|
boost::detail::ms_noinit(p2, n1);
|
||||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||||
a2->set(p2);
|
a2->set(p2);
|
||||||
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
return shared_ptr<T>(s1, p1);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,10 +147,10 @@ namespace boost {
|
|||||||
D1 d1;
|
D1 d1;
|
||||||
A1 a1(&p2);
|
A1 a1(&p2);
|
||||||
shared_ptr<T> s1(p1, d1, a1);
|
shared_ptr<T> s1(p1, d1, a1);
|
||||||
p1 = reinterpret_cast<T1*>(p2);
|
|
||||||
boost::detail::ms_noinit(p2, N);
|
boost::detail::ms_noinit(p2, N);
|
||||||
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
A1* a2 = static_cast<A1*>(s1._internal_get_untyped_deleter());
|
||||||
a2->set(p2);
|
a2->set(p2);
|
||||||
|
p1 = reinterpret_cast<T1*>(p2);
|
||||||
return shared_ptr<T>(s1, p1);
|
return shared_ptr<T>(s1, p1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,14 +13,14 @@
|
|||||||
#include <boost/smart_ptr/detail/array_traits.hpp>
|
#include <boost/smart_ptr/detail/array_traits.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
template<typename T>
|
template<class T>
|
||||||
inline typename boost::detail::up_if_array<T>::type
|
inline typename boost::detail::up_if_array<T>::type
|
||||||
make_unique(std::size_t size) {
|
make_unique(std::size_t size) {
|
||||||
typedef typename boost::detail::array_inner<T>::type U;
|
typedef typename boost::detail::array_inner<T>::type U;
|
||||||
return std::unique_ptr<T>(new U[size]());
|
return std::unique_ptr<T>(new U[size]());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
inline typename boost::detail::up_if_array<T>::type
|
inline typename boost::detail::up_if_array<T>::type
|
||||||
make_unique_noinit(std::size_t size) {
|
make_unique_noinit(std::size_t size) {
|
||||||
typedef typename boost::detail::array_inner<T>::type U;
|
typedef typename boost::detail::array_inner<T>::type U;
|
||||||
|
@@ -14,27 +14,27 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
template<typename T>
|
template<class T>
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
inline typename boost::detail::up_if_not_array<T>::type
|
||||||
make_unique() {
|
make_unique() {
|
||||||
return std::unique_ptr<T>(new T());
|
return std::unique_ptr<T>(new T());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
#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
|
inline typename boost::detail::up_if_not_array<T>::type
|
||||||
make_unique(Args&&... args) {
|
make_unique(Args&&... args) {
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template<class T>
|
||||||
inline typename boost::detail::up_if_not_array<T>::type
|
inline typename boost::detail::up_if_not_array<T>::type
|
||||||
make_unique(T&& value) {
|
make_unique(T&& value) {
|
||||||
return std::unique_ptr<T>(new T(std::move(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
|
inline typename boost::detail::up_if_not_array<T>::type
|
||||||
make_unique_noinit() {
|
make_unique_noinit() {
|
||||||
return std::unique_ptr<T>(new T);
|
return std::unique_ptr<T>(new T);
|
||||||
|
Reference in New Issue
Block a user