make_local_shared_array.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright 2017 Peter Dimov
  3. Copyright 2017 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 detail::lsp_if_size_array<T>::type
  14. make_local_shared()
  15. {
  16. return boost::allocate_local_shared<T>(std::allocator<typename
  17. detail::sp_array_scalar<T>::type>());
  18. }
  19. template<class T>
  20. inline typename detail::lsp_if_size_array<T>::type
  21. make_local_shared(const typename detail::sp_array_element<T>::type& value)
  22. {
  23. return boost::allocate_local_shared<T>(std::allocator<typename
  24. detail::sp_array_scalar<T>::type>(), value);
  25. }
  26. template<class T>
  27. inline typename detail::lsp_if_array<T>::type
  28. make_local_shared(std::size_t size)
  29. {
  30. return boost::allocate_local_shared<T>(std::allocator<typename
  31. detail::sp_array_scalar<T>::type>(), size);
  32. }
  33. template<class T>
  34. inline typename detail::lsp_if_array<T>::type
  35. make_local_shared(std::size_t size,
  36. const typename detail::sp_array_element<T>::type& value)
  37. {
  38. return boost::allocate_local_shared<T>(std::allocator<typename
  39. detail::sp_array_scalar<T>::type>(), size, value);
  40. }
  41. template<class T>
  42. inline typename detail::lsp_if_size_array<T>::type
  43. make_local_shared_noinit()
  44. {
  45. return allocate_local_shared_noinit<T>(std::allocator<typename
  46. detail::sp_array_scalar<T>::type>());
  47. }
  48. template<class T>
  49. inline typename detail::lsp_if_array<T>::type
  50. make_local_shared_noinit(std::size_t size)
  51. {
  52. return allocate_local_shared_noinit<T>(std::allocator<typename
  53. detail::sp_array_scalar<T>::type>(), size);
  54. }
  55. } /* boost */
  56. #endif