Skip to content

Instantly share code, notes, and snippets.

  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
WinRT(C++/CX) type conversion between Platform::String^ and std::string
#include <string>
std::string Managed_Str_To_Std_Str(Platform::String^ ms)
std::wstring w_str(ms->Begin());
return std::string(w_str.begin(), w_str.end());
Platform::String^ Std_Str_To_Managed_Str(const std::string & input)
std::wstring w_str = std::wstring(input.begin(), input.end());
const wchar_t* w_chars = w_str.c_str();
return (ref new Platform::String(w_chars));
Copy link

line 6 (return std::string) generates this error message now

see reference to function template instantiation 'std::basic_string<char,std::char_traits,std::allocator>::basic_string<std::_String_iterator<std::_String_val<std::_Simple_types<_Elem>>>,0>(_Iter,_Iter,const _Alloc &)' being compiled

can you explain why this error message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment