string_view.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // Copyright (c) 2019 Vinnie Falco ([email protected])
  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. #ifdef BOOST_JSON_DOCS
  20. /** The type of string view used by the library.
  21. The type has API equivalent to that of `std::string_view` and is
  22. convertible to/from it.
  23. */
  24. using string_view = __see_below__;
  25. #else
  26. using string_view = boost::core::string_view;
  27. #endif
  28. namespace detail {
  29. template<class T>
  30. using is_string_viewish = typename std::enable_if<
  31. std::is_convertible<
  32. T const&, string_view>::value &&
  33. ! std::is_convertible<
  34. T const&, char const*>::value
  35. >::type;
  36. } // detail
  37. } // namespace json
  38. } // namespace boost
  39. #endif