/*============================================================================= Copyright (c) 2011-2016 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout 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) =============================================================================*/ #ifndef SPROUT_UTILITY_STRING_REF_STRING_VIEW_HPP #define SPROUT_UTILITY_STRING_REF_STRING_VIEW_HPP #include #include #include #include namespace sprout { // // string_view // wstring_view // u16string_view // u32string_view // typedef sprout::basic_string_ref string_view; typedef sprout::basic_string_ref wstring_view; #if SPROUT_USE_UNICODE_LITERALS typedef sprout::basic_string_ref u16string_view; typedef sprout::basic_string_ref u32string_view; #endif #if SPROUT_USE_TEMPLATE_ALIASES // // basic_string_view // template > using basic_string_view = sprout::basic_string_ref; #endif // #if SPROUT_USE_TEMPLATE_ALIASES // // to_string_view // template inline SPROUT_CONSTEXPR sprout::basic_string_ref to_string_view(sprout::basic_string_ref const& s) { return sprout::to_string_ref(s); } template inline SPROUT_CONSTEXPR sprout::basic_string_ref to_string_view(sprout::basic_string const& s) { return sprout::to_string_ref(s); } template inline SPROUT_NON_CONSTEXPR sprout::basic_string_ref to_string_view(std::basic_string const& s) { return sprout::to_string_ref(s); } template inline SPROUT_CONSTEXPR sprout::basic_string_ref to_string_view(T const* str) { return sprout::to_string_ref(str); } template inline SPROUT_CONSTEXPR sprout::basic_string_ref to_string_view(T const* str, std::size_t len) { return sprout::to_string_ref(str, len); } // // is_basic_string_view // #if SPROUT_USE_TEMPLATE_ALIASES template using is_basic_string_view = sprout::is_basic_string_ref; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_basic_string_view : public sprout::is_basic_string_ref {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES // // is_string_view_of // #if SPROUT_USE_TEMPLATE_ALIASES template using is_string_view_of = sprout::is_string_ref_of; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_string_view_of : public sprout::is_string_ref_of {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES // // is_string_view // #if SPROUT_USE_TEMPLATE_ALIASES template using is_string_view = sprout::is_string_ref; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_string_view : public sprout::is_string_ref {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES // // is_wstring_view // #if SPROUT_USE_TEMPLATE_ALIASES template using is_wstring_view = sprout::is_wstring_ref; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_wstring_view : public sprout::is_wstring_ref {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES #if SPROUT_USE_UNICODE_LITERALS // // is_u16string_view // #if SPROUT_USE_TEMPLATE_ALIASES template using is_u16string_view = sprout::is_u16string_ref; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_u16string_view : public sprout::is_u16string_ref {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES // // is_u32string_view // #if SPROUT_USE_TEMPLATE_ALIASES template using is_u32string_view = sprout::is_u32string_ref; #else // #if SPROUT_USE_TEMPLATE_ALIASES template struct is_u32string_view : public sprout::is_u32string_ref {}; #endif // #if SPROUT_USE_TEMPLATE_ALIASES #endif #if SPROUT_USE_VARIABLE_TEMPLATES template SPROUT_STATIC_CONSTEXPR bool is_basic_string_view_v = sprout::is_basic_string_view::value; template SPROUT_STATIC_CONSTEXPR bool is_string_view_of_v = sprout::is_string_view_of::value; template SPROUT_STATIC_CONSTEXPR bool is_string_view_v = sprout::is_string_view::value; template SPROUT_STATIC_CONSTEXPR bool is_wstring_view_v = sprout::is_wstring_view::value; #if SPROUT_USE_UNICODE_LITERALS template SPROUT_STATIC_CONSTEXPR bool is_u16string_view_v = sprout::is_u16string_view::value; template SPROUT_STATIC_CONSTEXPR bool is_u32string_view_v = sprout::is_u32string_view::value; #endif #endif // #if SPROUT_USE_VARIABLE_TEMPLATES namespace udl { // // _sv // inline SPROUT_CONSTEXPR sprout::basic_string_ref operator"" _sv(char const* s, std::size_t size) { return sprout::basic_string_ref(s, size); } inline SPROUT_CONSTEXPR sprout::basic_string_ref operator"" _sv(wchar_t const* s, std::size_t size) { return sprout::basic_string_ref(s, size); } #if SPROUT_USE_UNICODE_LITERALS inline SPROUT_CONSTEXPR sprout::basic_string_ref operator"" _sv(char16_t const* s, std::size_t size) { return sprout::basic_string_ref(s, size); } inline SPROUT_CONSTEXPR sprout::basic_string_ref operator"" _sv(char32_t const* s, std::size_t size) { return sprout::basic_string_ref(s, size); } #endif } // namespace udl using sprout::udl::operator"" _sv; } // namespace sprout #endif // #ifndef SPROUT_UTILITY_STRING_REF_STRING_VIEW_HPP