forked from boostorg/smart_ptr
Spatial optimization for make_shared for arrays
Saves up to sizeof(void*) + sizeof(size_t) bytes for make_shared and saves sizeof(void*) + sizeof(size_t) + sizeof(A) bytes for allocate_shared where A is the supplied allocator type.
This commit is contained in:
1 parent
260af64027
commit
5f485c2952
9 files changed
+460
-465
No files matched your search
@@ -9,48 +9,48 @@
|
||||
#ifndef BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
|
||||
#define BOOST_SMART_PTR_DETAIL_ARRAY_TRAITS_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <boost/type_traits/remove_cv.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct array_base {
|
||||
typedef T type;
|
||||
typedef typename boost::remove_cv<T>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct array_base<T[]> {
|
||||
typedef typename array_base<T>::type type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
template<class T, std::size_t N>
|
||||
struct array_base<T[N]> {
|
||||
typedef typename array_base<T>::type type;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct array_total {
|
||||
enum {
|
||||
size = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
template<class T, std::size_t N>
|
||||
struct array_total<T[N]> {
|
||||
enum {
|
||||
size = N * array_total<T>::size
|
||||
};
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct array_inner;
|
||||
|
||||
template<typename T>
|
||||
template<class T>
|
||||
struct array_inner<T[]> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
template<class T, std::size_t N>
|
||||
struct array_inner<T[N]> {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user