Boost logo

Boost :

From: Simon Buchan (simon_at_[hidden])
Date: 2005-10-11 01:36:52


Try not to reply to digests: we lose the Subject at minimum.

Jared McIntyre wrote:
>>Double check that a is polymorphic - that is, that it has at least one
>>virtual function. Then get back to us.
>
>
> Yup, the destructors are virtual (and dynamic_cast is working in both directions). However, it works now (see later
> comment).
>
>
>>nope, its correct. This is a little known quirk of C++ syntax. Your second
>>version won't compile on the most conforming compilers.
>
>
> Nifty. I swear that didn't compile when I used it on Friday, but now it does. Now that I have changed it to that
> format, ar.template register_type<derived_one>(), it works. Out of curiosity, what is the difference between calling
> it that way and calling ar.register_type<derived_one>()? I've not seen that type of format and would be interested in
> learning more about it.
>
Here's a hint:
const int i = 2742;

struct foo1
{
        int bar;
};

struct foo2
{
        template <int sz>
        int bar(int i) {return sz + i;}
};

// unused template param
template <int sz>
void fn(foo1& f1, foo2& f2)
{ bool stupidbool = f1.bar<sz>(0);
        int stupidint = f2.bar<sz>(0);
}

int main()
{ fn<i>(foo1(), foo2());
}


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