From: Rob Stewart (stewart_at_[hidden])
Date: 2004-12-10 12:16:30
From: David Abrahams <dave_at_[hidden]>
> Rob Stewart wrote:
> > From: "Yuval Ronen" <ronen_yuval_at_[hidden]>
> > But you can't. You have to write the following, as I showed
> > above:
> > int a = some_any.template get<int>();
> ?? There are no dependent types in that utterance. Unless some_any is
> not known to be a boost::any (?) Am I missing something?
I tried to track down the relevant section in the standard to
confirm what I wrote, but I couldn't. I was relying on C++PL,
3rd Ed, App C, section C.13.6, "Template as a Qualifier."
The example is (reduced):
template <typename T> T * get_new();
template <typename Allocator>
f(Allocator & m)
int * p1 = m.get_new<int>(); // error
int * p2 = m.template get_new<int>();
This Memory::get_new() is used within a function template, but
Stroustrup doesn't mention that it is precisely because get_new()
is dependent that "template" is needed, so I didn't think that it
was a dependent type.
Thinking further, I realized that m.get_new<int>() actually means
m.Allocator::get_new<int>(), so I now see that it is a dependent
type according to 126.96.36.199/1.
In the OP's case, the invoked member function would be any<T>'s,
not T's, so it isn't dependent and "template" isn't needed, which
is what you implied.
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk