
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 Jared McIntyre wrote: <snip>
Also, there is an issue in the documentation. In the "Pointers to Objects of Derived Classes" section, it has example registration code:
main(){ ... ar.template register_type<derived_one>(); ar.template register_type<derived_two>(); base *b; ar & b; }
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
whoops - wrong again. If ar is a template you need "ar.template" other wise you shouldn't have it. 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. So I actually prefer the universal, idiot proof workaround: ar.register_type(static_cast<derived_one *>(NULL)) which works on all compilers conforming or not regardless of whether ar is a template or not. Robert Ramey
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost