Cosmetic changes in make_shared and make_unique

This commit is contained in:
Glen Fernandes
2014-02-10 21:04:41 -08:00
parent 5f485c2952
commit 57dc400fbf
6 changed files with 24 additions and 24 deletions

View File

@ -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;
};

View File

@ -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]> {
};
}

View File

@ -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);
}
@ -124,10 +124,10 @@ namespace boost {
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);
}
}

View File

@ -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;

View File

@ -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);