rename std::list::iterator

Hi, i want to shorter name of std::list::iterator, like std::list::myit.
thanks.
Letting the compiler deduce the type of the iterator leads to mode readable, maintainable code.
http://www.stroustrup.com/C++11FAQ.html#auto

Otherwise, use a template alias: http://www.stroustrup.com/C++11FAQ.html#template-alias

1
2
3
4
5
6
7
8
9
10
template < typename T > using sliter = typename std::list<T>::iterator ;

auto fancy_size( std::list<int> lst ) // let the compiler figure out what the return type is
{
    sliter<int> a = lst.begin() ; // use the template alias

    auto b = lst.end() ; // let the compiler figure out what the type of the iterator is

    return std::distance( a, b ) ;
}
Topic archived. No new replies allowed.