From 2ea3679220df1960f996df1992b25b70ed0444a1 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 13 Jun 2015 16:50:51 +0200 Subject: [PATCH] wide string: To{W,}String: provide overload for rvalue references --- src/utility/wide_string.cpp | 12 ------------ src/utility/wide_string.h | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/utility/wide_string.cpp b/src/utility/wide_string.cpp index 7f3cd8fd..a20b7f2c 100644 --- a/src/utility/wide_string.cpp +++ b/src/utility/wide_string.cpp @@ -18,21 +18,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ -#include // include before boost to compile on MACOSX -#include #include #include "utility/wide_string.h" -std::string ToString(const std::wstring &ws) -{ - return boost::locale::conv::utf_to_utf(ws); -} - -std::wstring ToWString(const std::string &s) -{ - return boost::locale::conv::utf_to_utf(s); -} - size_t wideLength(const std::wstring &ws) { size_t result = 0; diff --git a/src/utility/wide_string.h b/src/utility/wide_string.h index 076dfe95..b863eb3a 100644 --- a/src/utility/wide_string.h +++ b/src/utility/wide_string.h @@ -21,10 +21,19 @@ #ifndef NCMPCPP_UTILITY_WIDE_STRING_H #define NCMPCPP_UTILITY_WIDE_STRING_H -#include +#include // include before boost to compile on MACOSX +#include -std::string ToString(const std::wstring &ws); -std::wstring ToWString(const std::string &s); +template +std::string ToString(StringT &&s) +{ + return boost::locale::conv::utf_to_utf(std::forward(s)); +} +template +std::wstring ToWString(StringT &&s) +{ + return boost::locale::conv::utf_to_utf(std::forward(s)); +} size_t wideLength(const std::wstring &ws); void wideCut(std::wstring &ws, size_t max_length);