Convert VisualC++ template to gcc

Rupert Wood me@rupey.net
Thu Oct 4 08:47:00 GMT 2007


efgee wrote:

> template <class T>
> T table<T>::operator[] (const string& key)
> {
>	for (reverse_iterator i = rbegin(); i != rend(); i++)

I think this needs to be:

    for (typename table<T>::reverse_iterator i = table<T>::rbegin();
             i != table<T>::rend(); i++)

and as a style point I'd use '++i' not 'i++'. For the versions of g++ I'm trying you also need to explicitly #include <stdexcept> to use out_of_range.

It's possible you could get away with adding less - I'm not a guru on this - but this now compiles fine on g++ 3.4.6, g++ 4.3 and VC++ 6.

Rup.



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________



More information about the Gcc-help mailing list