wide string: To{W,}String: provide overload for rvalue references

This commit is contained in:
Andrzej Rybczak
2015-06-13 16:50:51 +02:00
parent b3c0c0798e
commit 2ea3679220
2 changed files with 12 additions and 15 deletions

View File

@@ -18,21 +18,9 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <string> // include before boost to compile on MACOSX
#include <boost/locale/encoding_utf.hpp>
#include <cassert>
#include "utility/wide_string.h"
std::string ToString(const std::wstring &ws)
{
return boost::locale::conv::utf_to_utf<char>(ws);
}
std::wstring ToWString(const std::string &s)
{
return boost::locale::conv::utf_to_utf<wchar_t>(s);
}
size_t wideLength(const std::wstring &ws)
{
size_t result = 0;

View File

@@ -21,10 +21,19 @@
#ifndef NCMPCPP_UTILITY_WIDE_STRING_H
#define NCMPCPP_UTILITY_WIDE_STRING_H
#include <string>
#include <string> // include before boost to compile on MACOSX
#include <boost/locale/encoding_utf.hpp>
std::string ToString(const std::wstring &ws);
std::wstring ToWString(const std::string &s);
template <typename StringT>
std::string ToString(StringT &&s)
{
return boost::locale::conv::utf_to_utf<char>(std::forward<StringT>(s));
}
template <typename StringT>
std::wstring ToWString(StringT &&s)
{
return boost::locale::conv::utf_to_utf<wchar_t>(std::forward<StringT>(s));
}
size_t wideLength(const std::wstring &ws);
void wideCut(std::wstring &ws, size_t max_length);