Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 -? Templates !
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Nov 19 2004 :  12:34:56 PM  Show Profile
It would be great when VAX could place the angle brackets and the cursor inside them when inserting a template function with required template parameters.
e.g.:
template<typename T> T FromStringTo( const std::string& text)

Here I have to provide a template parameter. After selecting this function from the suggestion or completion list, I have to go back, insert the <>'s and the type, then I can add the function parameters.

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Nov 22 2004 :  4:23:14 PM  Show Profile
i dont follow. this function takes a std::string as a parameter, not a template.
could you post a few more lines of code, so i can follow what you are doing?

zen is the art of being at one with the two'ness
Go to Top of Page

rblondeau
Tomato Guru

Canada
102 Posts

Posted - Nov 22 2004 :  5:33:51 PM  Show Profile
feline, a std::string is just a typedef for a basic_string<char> so it is a template parameter.

Here's the definition of std::string:
typedef basic_string<char> string
Go to Top of Page

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Nov 23 2004 :  12:11:53 PM  Show Profile
quote:
Originally posted by feline

i dont follow. this function takes a std::string as a parameter, not a template.
could you post a few more lines of code, so i can follow what you are doing?



Well, the function parameter is a std::string, but since the function itself is a template, it needs a template parameter.
Sample:

// Definition of the template function
template<typename T> T FromStringTo( const std::string& text);
// using it
long value = FromStringTo<long>("99");

As you can see, you have the template parameter in the angle brackets. But when inserting the function name, VAX does not care for them, and inserts only FromStringTo(|).
Clearer now?
Go to Top of Page

feline
Whole Tomato Software

United Kingdom
19022 Posts

Posted - Nov 23 2004 :  4:55:03 PM  Show Profile
yes, that makes sense now i do use template classes fairly often, and have even written a few, but i am not yet familiar with template functions. this forum is definitely educational

case=460

zen is the art of being at one with the two'ness
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000