473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

System::StringBuilder cannot be modified through template functions

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

Nov 17 '05 #1
0 949

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Loi | last post by:
Hi All, I use Bulk insert to put data to myTable. When the SQL server is in local machin, it works well. But when I put the data in a sql server situated not locally, then I get a error message...
2
by: avishosh | last post by:
Hi, I'm getting the folowing error when tring to open xml file: -------------------------------------------------------------------------------- The system cannot locate the resource specified....
0
by: SampathTangudu | last post by:
Hi, We are trying to use the Hash Tables for passing information from one aspx page to another aspx page. We are using the below code. IsolatedStorageFile isoStore =...
8
by: Michael | last post by:
I am running a web server (IIS) on Windows 2003 SP 1. My ASP.NET C# applications run fine. However, my application is a combination of Classic ASP and C#. For some reason when you attempt to...
6
by: chanmm | last post by:
Dear all, I have run the same web application in my Windows XP Pro without any problem but once I deploy it in Windows 2003 Server the message below appear: The system cannot find the file...
9
by: gamehack | last post by:
Hi all, I've been thinking about all the system functions which accept wchar_t. The point is that they don't define what encoding the wchar_t has to be. Let us assume that all the exernal input...
0
by: SushiSean | last post by:
When executing the xmlhttp.send function to request shipper for available shipments (I send xml as string and receive result xml): XMLHTTP xmlhttp = new XMLHTTP(); xmlhttp.open("POST",...
0
by: Curious | last post by:
Hi, I'm not sure if this is the right place to post such command issues. If you know a better forum where people respond to messages fairly often, please let me know! Anyway, would appreciate...
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
0
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgRGVzYXJyb2xsbw==?= | last post by:
Hi all, my problem is about services. I try comment you all steps for my issue: My development environment: Windows XP SP2
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.