Boost logo

Boost :

From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2005-10-11 17:22:22


Robert Ramey wrote:

> void serialize(my_archive & ar, T &t, const unsigned int version){
> ...
> ar.template register_type<T>(); // syntax error? or not?

Syntax error, if 'my_archive' is a real (as opposed to 'dependent') type.

> ...
> }
>
> Truth is I can't never keep these kinds of rules straight.

If the type 'ar' is dependent on template parameters, the compiler
can't look up symbols inside it, as these symbols may have different
bindings for different template specializations of 'ar'.

Thus, to make further parsing possible you have to tell the compiler
to treat the following token as a template-name, or else 'register_type<T'
will be parsed as a relational expression involving operands register_type and T.

HTH,
                Stefan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk