size.hpp 519 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. Copyright 2023 Glen Joseph Fernandes
  3. ([email protected])
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_CORE_SIZE_HPP
  8. #define BOOST_CORE_SIZE_HPP
  9. #include <cstddef>
  10. namespace boost {
  11. template<class C>
  12. inline constexpr auto
  13. size(const C& c) noexcept(noexcept(c.size())) -> decltype(c.size())
  14. {
  15. return c.size();
  16. }
  17. template<class T, std::size_t N>
  18. inline constexpr std::size_t
  19. size(T(&)[N]) noexcept
  20. {
  21. return N;
  22. }
  23. } /* boost */
  24. #endif