string_view.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.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. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_STRING_VIEW_HPP
  10. #define BOOST_JSON_STRING_VIEW_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/core/detail/string_view.hpp>
  13. #include <type_traits>
  14. #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
  15. # include <string_view>
  16. #endif
  17. namespace boost {
  18. namespace json {
  19. /** The type of string view used by the library.
  20. The type has API equivalent to that of @ref std::string_view and is
  21. convertible to and from it.
  22. */
  23. using string_view =
  24. #ifdef BOOST_JSON_DOCS
  25. __see_below__;
  26. #else
  27. boost::core::string_view;
  28. #endif
  29. namespace detail {
  30. template<class T>
  31. using is_string_viewish = typename std::enable_if<
  32. std::is_convertible<
  33. T const&, string_view>::value &&
  34. ! std::is_convertible<
  35. T const&, char const*>::value
  36. >::type;
  37. } // detail
  38. } // namespace json
  39. } // namespace boost
  40. #endif