forked from boostorg/smart_ptr
Minor cosmetic changes in make_shared for arrays
This commit is contained in:
1 parent
db78d9b2be
commit
87e5debdc2
8 files changed
+103
-91
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP
|
||||
#define BOOST_SMART_PTR_DETAIL_ARRAY_DELETER_HPP
|
||||
|
||||
#include <boost/smart_ptr/detail/array_traits.hpp>
|
||||
#include <boost/smart_ptr/detail/array_utility.hpp>
|
||||
|
||||
namespace boost {
|
||||
@@ -35,9 +36,9 @@ namespace boost {
|
||||
object = memory;
|
||||
}
|
||||
|
||||
template<std::size_t M>
|
||||
void init(T* memory, const T* list) {
|
||||
array_init<T, M>(memory, size, list);
|
||||
template<std::size_t N>
|
||||
void init(T* memory, const T* value) {
|
||||
array_init<T, N>(memory, size, value);
|
||||
object = memory;
|
||||
}
|
||||
|
||||
@@ -77,8 +78,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template<std::size_t M>
|
||||
void init(T* memory, const T* list) {
|
||||
array_init<T, M>(memory, N, list);
|
||||
void init(T* memory, const T* value) {
|
||||
array_init<T, M>(memory, N, value);
|
||||
object = memory;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
|
||||
#define BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
|
||||
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
struct array_base {
|
||||
typedef typename boost::remove_cv<T>::type type;
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
inline void array_destroy(T*, std::size_t, boost::true_type) {
|
||||
inline void array_destroy(T*, std::size_t,
|
||||
boost::true_type) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void array_destroy(T* memory, std::size_t size, boost::false_type) {
|
||||
inline void array_destroy(T* memory, std::size_t size,
|
||||
boost::false_type) {
|
||||
for (std::size_t i = size; i > 0; ) {
|
||||
memory[--i].~T();
|
||||
}
|
||||
@@ -33,7 +35,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void array_value(T* memory, std::size_t size, boost::true_type) {
|
||||
inline void array_value(T* memory, std::size_t size,
|
||||
boost::true_type) {
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
void* p1 = memory + i;
|
||||
::new(p1) T();
|
||||
@@ -41,7 +44,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void array_value(T* memory, std::size_t size, boost::false_type) {
|
||||
inline void array_value(T* memory, std::size_t size,
|
||||
boost::false_type) {
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
@@ -68,7 +72,8 @@ namespace boost {
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
inline void array_init(T* memory, std::size_t size, const T* list) {
|
||||
inline void array_init(T* memory, std::size_t size,
|
||||
const T* list) {
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
@@ -89,11 +94,13 @@ namespace boost {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void array_default(T*, std::size_t, boost::true_type) {
|
||||
inline void array_default(T*, std::size_t,
|
||||
boost::true_type) {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void array_default(T* memory, std::size_t size, boost::false_type) {
|
||||
inline void array_default(T* memory, std::size_t size,
|
||||
boost::false_type) {
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
std::size_t i = 0;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user