I try to be const correct everywhere and found that I can't pass a const
String to this API. Is it going to change the value? Or is the signature
not the best it could be?
I want to write this:
// based on http://msdn.microsoft.com/en-us/magazine/bb985936.aspx
std::string MarshalString (const System::String^ s)
{
using namespace System::Runtime::InteropServices;
const char* chars =
(const char*)(Marshal::StringToHGlobalAnsi
(s)).ToPointer();
os = chars;
Marshal::FreeHGlobal(IntPtr((void*)chars));
return os;
}
Should I copy the argument and convert the copy?