string_view.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // detail/string_view.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_STRING_VIEW_HPP
  11. #define BOOST_ASIO_DETAIL_STRING_VIEW_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #if defined(BOOST_ASIO_HAS_STRING_VIEW)
  17. #if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
  18. # include <string_view>
  19. #elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  20. # include <experimental/string_view>
  21. #else // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  22. # error BOOST_ASIO_HAS_STRING_VIEW is set but no string_view is available
  23. #endif // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  24. namespace boost {
  25. namespace asio {
  26. #if defined(BOOST_ASIO_HAS_STD_STRING_VIEW)
  27. using std::basic_string_view;
  28. using std::string_view;
  29. #elif defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  30. using std::experimental::basic_string_view;
  31. using std::experimental::string_view;
  32. #endif // defined(BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW)
  33. } // namespace asio
  34. } // namespace boost
  35. # define BOOST_ASIO_STRING_VIEW_PARAM boost::asio::string_view
  36. #else // defined(BOOST_ASIO_HAS_STRING_VIEW)
  37. # define BOOST_ASIO_STRING_VIEW_PARAM const std::string&
  38. #endif // defined(BOOST_ASIO_HAS_STRING_VIEW)
  39. #endif // BOOST_ASIO_DETAIL_STRING_VIEW_HPP