Don't use the convert variable inside the to_wstring function. It will make it perform slower.
std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> conv_; std::string wideToStr(const std::wstring& wstr) { return conv_.to_bytes(wstr); } std::wstring strToWide(const std::string& str) { return conv_.from_bytes(str); }