Index: src/mpt/string/types.hpp =================================================================== --- src/mpt/string/types.hpp (revision 18621) +++ src/mpt/string/types.hpp (working copy) @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -504,11 +505,11 @@ template -inline typename mpt::make_string_type::type as_string(const T & str) { - if constexpr (std::is_pointer::type>::value) { - return str ? typename mpt::make_string_type::type{str} : typename mpt::make_string_type::type{}; - } else if constexpr (mpt::is_string_view_type::value) { - return typename mpt::make_string_type::type{str}; +inline typename mpt::make_string_type::type>::type as_string(T && str) { + if constexpr (std::is_pointer::type>::value) { + return str ? typename mpt::make_string_type::type>::type{std::forward(str)} : typename mpt::make_string_type::type>::type{}; + } else if constexpr (mpt::is_string_view_type::type>::value) { + return typename mpt::make_string_type::type>::type{std::forward(str)}; } else { return str; } @@ -517,11 +518,11 @@ template -inline typename mpt::make_string_view_type::type as_string_view(const T & str) { - if constexpr (std::is_pointer::type>::value) { - return str ? typename mpt::make_string_view_type::type{str} : typename mpt::make_string_view_type::type{}; - } else if constexpr (mpt::is_string_view_type::value) { - return typename mpt::make_string_view_type::type{str}; +inline typename mpt::make_string_view_type::type>::type as_string_view(T && str) { + if constexpr (std::is_pointer::type>::value) { + return str ? typename mpt::make_string_view_type::type>::type{std::forward(str)} : typename mpt::make_string_view_type::type>::type{}; + } else if constexpr (mpt::is_string_view_type::type>::value) { + return typename mpt::make_string_view_type::type>::type{std::forward(str)}; } else { return str; } Index: src/mpt/string_transcode/transcode.hpp =================================================================== --- src/mpt/string_transcode/transcode.hpp (revision 18621) +++ src/mpt/string_transcode/transcode.hpp (working copy) @@ -25,6 +25,7 @@ #if !defined(MPT_COMPILER_QUIRK_NO_WCHAR) #include #endif // !MPT_COMPILER_QUIRK_NO_WCHAR +#include #include #if MPT_OS_DJGPP @@ -1891,28 +1892,28 @@ #endif // MPT_DETECTED_MFC -template ::type>::value, bool> = true> -inline Tdststring transcode(const Tsrcstring & src) { - if constexpr (std::is_same::type>::value) { - return mpt::as_string(src); +template ::type>::type>::value, bool> = true> +inline Tdststring transcode(Tsrcstring && src) { + if constexpr (std::is_same::type>::type>::value) { + return mpt::as_string(std::forward(src)); } else { - return string_transcoder::encode(string_transcoder::decode(mpt::as_string(src))); + return string_transcoder::encode(string_transcoder(src)))>::decode(mpt::as_string(std::forward(src)))); } } -template ::value, bool> = true, std::enable_if_t::type>::value, bool> = true> -inline Tdststring transcode(Tencoding to, const Tsrcstring & src) { - return mpt::encode(to, string_transcoder::decode(mpt::as_string(src))); +template ::value, bool> = true, std::enable_if_t::type>::type>::value, bool> = true> +inline Tdststring transcode(Tencoding to, Tsrcstring && src) { + return mpt::encode(to, string_transcoder(src)))>::decode(mpt::as_string(std::forward(src)))); } -template ::type, std::string>::value, bool> = true, std::enable_if_t::type>::value, bool> = true> -inline Tdststring transcode(Tencoding from, const Tsrcstring & src) { - return string_transcoder::encode(mpt::decode(from, mpt::as_string(src))); +template ::type>::type, std::string>::value, bool> = true, std::enable_if_t::type>::type>::value, bool> = true> +inline Tdststring transcode(Tencoding from, Tsrcstring && src) { + return string_transcoder::encode(mpt::decode(src)))>(from, mpt::as_string(std::forward(src)))); } -template ::type>::value, bool> = true> -inline Tdststring transcode(Tto to, Tfrom from, const Tsrcstring & src) { - return mpt::encode(to, mpt::decode(from, mpt::as_string(src))); +template ::type>::type>::value, bool> = true> +inline Tdststring transcode(Tto to, Tfrom from, Tsrcstring && src) { + return mpt::encode(to, mpt::decode(src)))>(from, mpt::as_string(std::forward(src)))); }