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 ::InteropServic es;
const char* chars =
(const char*)(Marshal: :StringToHGloba lAnsi
(s)).ToPointer( );
os = chars;
Marshal::FreeHG lobal(IntPtr((v oid*)chars));
return os;
}
Should I copy the argument and convert the copy?
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 ::InteropServic es;
const char* chars =
(const char*)(Marshal: :StringToHGloba lAnsi
(s)).ToPointer( );
os = chars;
Marshal::FreeHG lobal(IntPtr((v oid*)chars));
return os;
}
Should I copy the argument and convert the copy?
Comment