Aliases

Hello,

I need to know if there is an easier to remember alias for :

std::string::const_iterator

In regexes I could replace match_results<string::iterator> with smatch.

It is so much easier that I would like to extend this to other things..

Any idea ?
I managed to find declarations of aliases but apart from namespace aliases, it is hard to understand.

Thanks !

Larry
If your compiler supports C++11, you can use "auto". You can always use
"#define AVeryShortStringToStdStringIterator std::string::const_iterator"
Instead of a #define you may want to consider using a typedef like so:
typedef std::string::const_iterator str_citer;
Thanks !
Lot of great ideas !

Ats15, what did you mean by auto ?

My compiler supports c++11.

Using the auto keyword asks the compiler to figure out the proper type at compile time for you. For example:
1
2
3
std::vector<int> v;
std::vector<int>::iterator i = v.begin(); // instead of this
auto i2 = v.begin(); // just write this 
Wonderful !!

it will ease my code a lot !

Since I do not intend to become the next c++ guru, it will be perfectly fine :)

Many thanks,

See you,

Larry
Last edited on
Topic archived. No new replies allowed.