Hi
changing a StringBuilder through a deduced type throws an exception - Sample Code
void editBuilder(System::Text::StringBuilder* t
System::String* insertThis = S"inserted"
t->EnsureCapacity(t->Length + insertThis->Length + 1)
std::cout << "Capacity: " << t->Capacity << "\n"
t->Insert(0,insertThis)
template<class R, class P> R Call(R(*function)(P),P param
return function(param)
int _tmain(
{
System::Text::StringBuilder* striBi = new System::Text::StringBuilder("XXXXXXXXXXXXXX")
editBuilder(striBi); // this works just fin
System::Text::StringBuilder* striBi2 = new System::Text::StringBuilder("XXXXXXXXXXXXXX")
tr
Call(editBuilder,striBi2); // exception here - see *belo
catch(System::Exception* ooopsie
Console::WriteLine(S"ooopsie: {0}", ooopsie->Message)
Console::WriteLine(S"Zusatzinfo:")
Console::WriteLine(S" {0}", ooopsie)
*below
System.ArgumentOutOfRangeException: requiredLengt
Parametername: Kapazität muss positiv sein
at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength
at System.Text.StringBuilder.Insert(Int32 index, String value, Int32 count
at System.Text.StringBuilder.Insert(Int32 index, String value)
Note that changing the Call Signature to
template<class R, class P> R Call(R(*function)(P),P& param
did not change a thin
Regards
Arn