Re: How `export' could be useful
David Abrahams wrote:
Walter Bright <walter@digitalmars-nospamm.com> writes:
where C++ got bizarre is when weird rules were added
like you cannot redeclare template parameters even within nested local
scopes, base member names are not found,...
of course they are found, if the base is non-dependent,
That is true, I should have mentioned that. Here's an excerpt from my
template talk at SDWest on the strange rules (example adapted from the
C++98 Standard):
int g(double d) { return 1; }
typedef double A;
template<class T> B
{
typedef int A;
};
template<class T> struct X : B<T>
{
A a; // a has type double
int T; // error, T redeclared
int foo()
{ char T; // error, T redeclared
return g(1); // always returns 1
}
};
int g(int i) { return 2; } // this definition not seen by X
and dependent base member names _can't_ be found
There is no technical reason why they cannot be. I had to actually
*break* finding them in DMC++ so it would be standard conformant.
Furthermore, in D, the template lookup rules actually work as one would
expect. The above example code written in D would be:
int g(double d) { return 1; }
typedef double A;
class B(T)
{
typedef int A;
}
class X(T) : B!(T)
{
A a; // a has type int
int T; // ok, T redeclared as int
int foo()
{ char T; // ok, T redeclared as char
return g(1); // always returns 2
}
};
int g(int i) { return 2; } // functions can be forward referenced
-Walter Bright
www.digitalmars.com C, C++, D programming language compilers
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]