Hi Tim,
Thomas Grill a écrit :
Hi Tim, this seems to be a speciality of the gcc 3.4 compiler... i'll have to check for that - a bit later
Yes, I'm using 3.3 here and the begin() and end() methods works fine... These changes between 3.3 and 3.4 are listed here :
http://gcc.gnu.org/gcc-3.4/changes.html#cplusplus
I think there are two passages that interests us, First :
You must now use the |typename| and |template| keywords to disambiguate dependent names, as required by the C++ standard.
struct K {
typedef int mytype_t;
};
template <class T1> struct A { template <class T2> struct B { void callme(void); };
template <int N> void bar(void)
{
// Use 'typename' to tell the parser that T1::mytype_t names
// a type. This is needed because the name is dependent (in
// this case, on template parameter T1).
typename T1::mytype_t x;
x = 0;
}
};
template <class T> void template_func(void)
{
// Use 'template' to prefix member templates within
// dependent types (a has type A<T>, which depends on
// the template parameter T).
A<T> a;
a.template bar<0>();
// Use 'template' to tell the parser that B is a nested
// template class (dependent on template parameter T), and
// 'typename' because the whole A<T>::B<int> is
// the name of a type (again, dependent).
typename A<T>::template B<int> b;
b.callme();
}
void non_template_func(void) { // Outside of any template class or function, no names can be // dependent, so the use of the keyword 'typename' and 'template' // is not needed (and actually forbidden). A<K> a; a.bar<0>(); A<K>::B<float> b; b.callme(); }
But I've checked the code and template and typename seems well placed...
Second :
In a template definition, unqualified names will no longer find members of a dependent base (as specified by [temp.dep]/3 in the C++ standard). For example,
template <typename T> struct B {
int m;
int n;
int f ();
int g ();
};
int n;
int g ();
template <typename T> struct C : B<T> {
void h ()
{
m = 0; // error
f (); // error
n = 0; // ::n is modified
g (); // ::g is called
}
};
You must make the names dependent, e.g. by prefixing them with |this->|. Here is the corrected definition of |C<T>::h|,
template <typename T> void C<T>::h ()
{
this->m = 0;
this->f ();
this->n = 0
this->g ();
}
Perhaps if you just add this-> before begin() and end() at lines 72 & 80, it will works, but it seems too simple.. I see no other differences but I'm not a C++ specialist, has anyone got an idea?
Greetings,
Nicolas