|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-10-11 17:28:31
"Robert Ramey" <ramey_at_[hidden]> writes:
> Hmmm - here is a situation that I come across:
>
> class my_archive {
> ....
> };
>
> template<class Arg>
> class my_templated_archive{
> };
>
> template<class Archive, T>
> void serialize(Archive & ar, T &t, const unsigned int version){
> ...
> ar.template register_type<T>(); // ok - I think
> ...
> }
Correct.
> void serialize(my_archive & ar, T &t, const unsigned int version){
> ...
> ar.template register_type<T>(); // syntax error? or not?
> ...
> }
Syntax error, at least unless and until the committee relaxes the
rules. my_archive is not a dependent type.
> Truth is I can't never keep these kinds of rules straight.
It's pretty simple: does the type of ar depend on a template
parameter? If so, we don't know whether ar.register_type is a value
or a class template and template is required. If not, we can simply
look at the type of ar and determine whether register_type is a
template or not, and the template keyword is forbidden.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk