make_local_shared_array.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. Copyright 2017 Peter Dimov
  3. Copyright 2017-2019 Glen Joseph Fernandes
  4. (glenjofe@gmail.com)
  5. Distributed under the Boost Software License, Version 1.0.
  6. (http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
  9. #define BOOST_SMART_PTR_MAKE_LOCAL_SHARED_ARRAY_HPP
  10. #include <boost/smart_ptr/allocate_local_shared_array.hpp>
  11. namespace boost {
  12. template<class T>
  13. inline typename enable_if_<is_bounded_array<T>::value,
  14. local_shared_ptr<T> >::type
  15. make_local_shared()
  16. {
  17. return boost::allocate_local_shared<T>(std::allocator<typename
  18. detail::sp_array_scalar<T>::type>());
  19. }
  20. template<class T>
  21. inline typename enable_if_<is_bounded_array<T>::value,
  22. local_shared_ptr<T> >::type
  23. make_local_shared(const typename remove_extent<T>::type& value)
  24. {
  25. return boost::allocate_local_shared<T>(std::allocator<typename
  26. detail::sp_array_scalar<T>::type>(), value);
  27. }
  28. template<class T>
  29. inline typename enable_if_<is_unbounded_array<T>::value,
  30. local_shared_ptr<T> >::type
  31. make_local_shared(std::size_t size)
  32. {
  33. return boost::allocate_local_shared<T>(std::allocator<typename
  34. detail::sp_array_scalar<T>::type>(), size);
  35. }
  36. template<class T>
  37. inline typename enable_if_<is_unbounded_array<T>::value,
  38. local_shared_ptr<T> >::type
  39. make_local_shared(std::size_t size,
  40. const typename remove_extent<T>::type& value)
  41. {
  42. return boost::allocate_local_shared<T>(std::allocator<typename
  43. detail::sp_array_scalar<T>::type>(), size, value);
  44. }
  45. template<class T>
  46. inline typename enable_if_<is_bounded_array<T>::value,
  47. local_shared_ptr<T> >::type
  48. make_local_shared_noinit()
  49. {
  50. return boost::allocate_local_shared_noinit<T>(std::allocator<typename
  51. detail::sp_array_scalar<T>::type>());
  52. }
  53. template<class T>
  54. inline typename enable_if_<is_unbounded_array<T>::value,
  55. local_shared_ptr<T> >::type
  56. make_local_shared_noinit(std::size_t size)
  57. {
  58. return boost::allocate_local_shared_noinit<T>(std::allocator<typename
  59. detail::sp_array_scalar<T>::type>(), size);
  60. }
  61. } /* boost */
  62. #endif