// Copyright Takatoshi Kondo 2016 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #if !defined(MQTT_STRING_VIEW_HPP) #define MQTT_STRING_VIEW_HPP #include #include #ifdef MQTT_STD_STRING_VIEW #include namespace MQTT_NS { using std::string_view; using std::basic_string_view; } // namespace MQTT_NS #else // MQTT_STD_STRING_VIEW #include #include #include namespace MQTT_NS { using string_view = boost::string_view; template > using basic_string_view = boost::basic_string_view; } // namespace MQTT_NS #endif // !defined(MQTT_STD_STRING_VIEW) namespace MQTT_NS { namespace detail { template T* to_address(T* p) noexcept { return p; } template auto to_address(const T& p) noexcept { return detail::to_address(p.operator->()); } } // namespace detail // Make a string_view from a pair of iterators. template string_view make_string_view(Begin begin, End end) { return string_view(detail::to_address(begin), static_cast(std::distance(begin, end))); } } // namespace MQTT_NS #endif // MQTT_STRING_VIEW_HPP