|
Boost : |
From: Simon Buchan (simon_at_[hidden])
Date: 2005-10-11 16:56:11
David Abrahams wrote:
> "Robert Ramey" <ramey_at_[hidden]> writes:
>
>
>>Simon Buchan wrote:
>>
>>>Robert Ramey wrote:
>>>
>>>>Double check that a is polymorphic - that is, that it has at least
>>>>one virtual function. Then get back to us.
>>>>
>>>>Robert Ramey
>>>>
>>>>>I'm guessing that is supposed to be:
>>>>>
>>>>>main(){
>>>>> ...
>>>>> ar.register_type<derived_one>();
>>>>> ar.register_type<derived_two>();
>>>>> base *b;
>>>>> ar & b;
>>>>>}
>>>>
>>>>
>>>>nope, its correct. This is a little known quirk of C++ syntax.
>>>>Your second version won't compile on the most conforming compilers.
>>>>
>>>Not according to Comeau:
>>>"ComeauTest.c", line 16: error: the "template" keyword used for
>>> syntactic disambiguation may only be used within a template
>>>
Quick note: Comeau (possibly the worlds most conforming compiler)
doesn't actually require the template disambiguator (despite allowing it
in the correct case), when I asked them why
(support_at_[hidden]), they replied with:
" We believe there is enough wiggle room and amibiguity in the standard
" about that requirement, and also, some direction that if the rule does
" exist, that it might be relaxed.
So basically, they don't think it's _really_ that required by the
standard. (Personally, I believe at least a warning in strict mode would
be nice)
>>whoops - wrong again. If ar is a template you need "ar.template" other wise
>>you shouldn't have it.
>
> Nope, wrong again. If ar's type X is dependent and "register_type" is a
> nested template in X, then you need "ar.template register_type<...>".
> Otherwise, you need "ar.register_type<...>"
>
A-la typename usage:
typename dependant_name::nested_type
dependant_name.template nested_template
>>From the above code it could be either. Its really annoying to me
>>to have to keep the context and provinence of a variable like "ar"
>>in my head while I'm writting.
>
> Guess what; you don't. If you had to know whether ar was a template
> or not, just think how impossible it would be to write generic code?
>
Well, you *do* have to know if ar is a class template, but not if it's a
template class, which is what I think you were trying to say.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk