
"Robert Ramey" <ramey@rrsd.com> 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
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<...>"
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? -- Dave Abrahams Boost Consulting www.boost-consulting.com