Re: syntax error in std::vector<T>::const_iterator where T = (class) U<V>
On Feb 8, 12:38 pm, "Paul" <pchris...@yahoo.co.uk> wrote:
"James Kanze" <james.ka...@gmail.com> wrote in message
news:751342be-2e1a-4f71-bc0a-275dcfabe41e@o7g2000prn.googlegroups.com...
[...]
struct A
{
// 'f' is a function
static void f() { std::cout << "A\n"; }
};
struct B
{
// 'f' is a type
struct f
{
f() { std::cout << "B\n"; }
};
};
int main()
{
foo<A>();
foo<B>(); // Fails because B::f is a type}
//---------------------------------------------------------------
That's what the standard requires.
I don't see why the compiler couldn't defer the decision in this
case; I suppose that the only reason it doesn't is to be
orthogonal with cases where it must know.
This doesn't happen on my compiler. MS 32-bit optimising compiler version
14.00......
Not all compilers are up to date concerning this. A lot
(included VC++ through 2005, at least) continue to defer all
template parsing until instantiation, at which point in time,
the meaning of f is unambiguously known. Implementing the
latest rules for name lookup in templates (aka breaking existing
code) isn't always the highest priority of compiler writers.
--
James Kanze