2012-11-06 14:17:32 +00:00
|
|
|
/*
|
2019-02-22 17:59:05 -05:00
|
|
|
Copyright 2012-2019 Glen Joseph Fernandes
|
2017-02-28 01:41:34 -05:00
|
|
|
(glenjofe@gmail.com)
|
|
|
|
|
|
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
|
|
(http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
2012-11-06 14:17:32 +00:00
|
|
|
#ifndef BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
|
|
|
|
#define BOOST_SMART_PTR_MAKE_SHARED_ARRAY_HPP
|
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
#include <boost/smart_ptr/allocate_shared_array.hpp>
|
2012-11-06 14:17:32 +00:00
|
|
|
|
|
|
|
namespace boost {
|
2014-01-23 20:40:46 -08:00
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
2017-02-28 01:41:34 -05:00
|
|
|
make_shared()
|
|
|
|
{
|
|
|
|
return boost::allocate_shared<T>(std::allocator<typename
|
|
|
|
detail::sp_array_scalar<T>::type>());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
|
|
|
make_shared(const typename remove_extent<T>::type& value)
|
2017-02-28 01:41:34 -05:00
|
|
|
{
|
|
|
|
return boost::allocate_shared<T>(std::allocator<typename
|
|
|
|
detail::sp_array_scalar<T>::type>(), value);
|
|
|
|
}
|
2014-01-23 20:40:46 -08:00
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
2017-02-28 01:41:34 -05:00
|
|
|
make_shared(std::size_t size)
|
|
|
|
{
|
|
|
|
return boost::allocate_shared<T>(std::allocator<typename
|
|
|
|
detail::sp_array_scalar<T>::type>(), size);
|
|
|
|
}
|
2014-01-23 20:40:46 -08:00
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
|
|
|
make_shared(std::size_t size, const typename remove_extent<T>::type& value)
|
2017-02-28 01:41:34 -05:00
|
|
|
{
|
|
|
|
return boost::allocate_shared<T>(std::allocator<typename
|
|
|
|
detail::sp_array_scalar<T>::type>(), size, value);
|
|
|
|
}
|
2014-01-23 20:40:46 -08:00
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_bounded_array<T>::value, shared_ptr<T> >::type
|
2017-02-28 01:41:34 -05:00
|
|
|
make_shared_noinit()
|
|
|
|
{
|
2019-02-22 17:59:05 -05:00
|
|
|
return boost::allocate_shared_noinit<T>(std::allocator<typename
|
2017-02-28 01:41:34 -05:00
|
|
|
detail::sp_array_scalar<T>::type>());
|
|
|
|
}
|
2014-01-23 20:40:46 -08:00
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
template<class T>
|
2019-02-22 17:59:05 -05:00
|
|
|
inline typename enable_if_<is_unbounded_array<T>::value, shared_ptr<T> >::type
|
2017-02-28 01:41:34 -05:00
|
|
|
make_shared_noinit(std::size_t size)
|
|
|
|
{
|
2019-02-22 17:59:05 -05:00
|
|
|
return boost::allocate_shared_noinit<T>(std::allocator<typename
|
2017-02-28 01:41:34 -05:00
|
|
|
detail::sp_array_scalar<T>::type>(), size);
|
2012-11-06 14:17:32 +00:00
|
|
|
}
|
|
|
|
|
2017-02-28 01:41:34 -05:00
|
|
|
} /* boost */
|
|
|
|
|
2012-11-06 14:17:32 +00:00
|
|
|
#endif
|