make_string_view.hpp 734 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_DETAIL_MAKE_STRING_VIEW_HPP
  8. #define BOOST_MYSQL_DETAIL_MAKE_STRING_VIEW_HPP
  9. #include <boost/mysql/string_view.hpp>
  10. namespace boost {
  11. namespace mysql {
  12. namespace detail {
  13. template <std::size_t N>
  14. constexpr string_view make_string_view(const char (&buff)[N]) noexcept
  15. {
  16. static_assert(N >= 1, "Expected a C-array literal");
  17. return string_view(buff, N - 1); // discard null terminator
  18. }
  19. } // namespace detail
  20. } // namespace mysql
  21. } // namespace boost
  22. #endif