"Victor Bazarov" <v.********@comAcast.net> wrote in message news:4W*******************@newsread1.mlpsca01.us.t o.verio.net...
Alex Vinokur wrote: "Victor Bazarov" <v.********@comAcast.net> wrote in message
news:Sy*******************@newsread1.mlpsca01.us.t o.verio.net...
Dietmar Kuehl wrote:
Alex Vinokur wrote:
> template <typename T> struct Foo { vector<int>::iterator iter1;
> typename vector<T>::iterator iter2; };
>
> int main() { Foo<double> f; return 0; } ---------------------
>
> Is iter1 a value? Is iter2 a typename?
You mean, I failed to mention that 'typename' is only necessary if
it applies to a dependent name? (and currently prohbited if not
necessary; it is discussed to change the latter rule) Fair enough:
both 'iter1' and 'iter2' are type names because 'iter1' does not
depend on a template parameter and it is guaranteed to the compiler
that 'iter2' is indeed a type name.
Uh... I somehow thought that 'iter1' and 'iter2' are member names.
V
It seems that _iterators_ in 'vector<int>::iterator' and 'typename
vector<T>::iterator' are type names (?).
Yes, they are. And it doesn't just seem so, it _is_ so. I was simply
surprised by the use of <<'iter1'>> and <<'iter2'>> in Dietmar's reply.
V
Here are a sample connected to the issue.
------ file.cpp ------
struct Foo
{
struct Bar {};
static void foo (int) {}
static int data;
};
int Foo::data(0);
template <typename T>
struct Blah
{
Foo::Bar b1; // 'Bar' is explicit type name, b1 is value
Foo::Bar (b2); // 'Bar' is explicit type name, b2 is value
// T::Bar b3; // 'Bar' is implicit type name
// T::Bar (b4); // 'Bar' is implicit type name
typename T::Bar b3; // Now 'Bar' is explicit type name, b3 is value
typename T::Bar (b4); // Now 'Bar' is explicit type name, b4 is value
void blah1 () { int x(0); T::foo(x); } // 'foo' is explicit function name
void blah2 () { T::data; } // 'data' is explicit value name
// ----------------------
void blah3 (Foo::Bar, typename T::Bar, void (*)(int), int) {}
// 'Bar' in Foo::Bar is explicit type name
// 'Bar' in T::Bar is now explicit type name
// ----------------------
};
int main()
{
Foo::Bar bar;
Blah<Foo> blah;
// ---------
blah.blah1();
blah.blah2();
// ---------
// ----------------------------------------
blah.blah3 (bar, bar, Foo::foo, Foo::data);
// 'foo' is explicit function name
// 'data' is explicit value name
// ----------------------------------------
return 0;
}
----------------------
See also
http://www.glenmccl.com/ansi_035.htm .
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn