From b9a0dde18149e820d77f1a2f8342888d318a0607 Mon Sep 17 00:00:00 2001 From: roker Date: Fri, 2 Jul 2021 15:13:49 +0200 Subject: [PATCH] add u16string_view. --- src/string_view.hh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/string_view.hh b/src/string_view.hh index 3506350..9ed099f 100644 --- a/src/string_view.hh +++ b/src/string_view.hh @@ -9,7 +9,11 @@ namespace pEp { - typedef std::string_view string_view; + template + using basic_string_view = std::basic_string_view; + + typedef std::string_view string_view; + typedef std::u16string_view u16string_view; } #else // in C++11 / C++14 use boost::string_view instead. @@ -17,18 +21,24 @@ namespace pEp namespace pEp { - typedef boost::string_view string_view; + template + using basic_string_view = boost::basic_string_view; + + typedef boost::string_view string_view; + typedef boost::u16string_view u16string_view; // boost::string_view does not provide these operations, neither by boost nor by the stdlib. :-( + template inline - std::string& operator+=(std::string& s, const string_view v) + std::basic_string& operator+=(std::basic_string& s, const basic_string_view v) { s.append(v.data(), v.size()); return s; } + template inline - std::string operator+(std::string s, const string_view v) + std::basic_string operator+(std::basic_string s, const basic_string_view v) { return s += v; }