make_span.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright 2023 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_CORE_MAKE_SPAN_HPP
  8. #define BOOST_CORE_MAKE_SPAN_HPP
  9. #include <boost/core/span.hpp>
  10. namespace boost {
  11. template<class I>
  12. inline constexpr span<I>
  13. make_span(I* f, std::size_t c) noexcept
  14. {
  15. return span<I>(f, c);
  16. }
  17. template<class I>
  18. inline constexpr span<I>
  19. make_span(I* f, I* l) noexcept
  20. {
  21. return span<I>(f, l);
  22. }
  23. template<class T, std::size_t N>
  24. inline constexpr span<T, N>
  25. make_span(T(&a)[N]) noexcept
  26. {
  27. return span<T, N>(a);
  28. }
  29. template<class T, std::size_t N>
  30. inline constexpr span<T, N>
  31. make_span(std::array<T, N>& a) noexcept
  32. {
  33. return span<T, N>(a);
  34. }
  35. template<class T, std::size_t N>
  36. inline constexpr span<const T, N>
  37. make_span(const std::array<T, N>& a) noexcept
  38. {
  39. return span<const T, N>(a);
  40. }
  41. template<class R>
  42. inline span<typename detail::span_data<R>::type>
  43. make_span(R&& r)
  44. {
  45. return span<typename detail::span_data<R>::type>(std::forward<R>(r));
  46. }
  47. } /* boost */
  48. #endif