Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-06-17 07:41:21


John Maddock wrote:
>> some code:
>>
>> template <typename DerivedT>
>> class A
>> {
>> BOOST_STATIC_ASSERT((boost::is_convertible<A<DerivedT>*,
>> B*>::value)); [...]
>> };
>>
>> class B : public A<B>
>> {
>> };
>>
>> I want to check if the template parameter really specifies a derived
>> type. But the assert is always false.
>> How can i solve this?
>
> I think your code should be:
>
> template <typename DerivedT>
> class A
> {
> BOOST_STATIC_ASSERT((::boost::is_convertible<DerivedT*,
> A<DerivedT>*>::value));
> // this should work as well:
> BOOST_STATIC_ASSERT((::boost::is_base_and_derived<A<DerivedT>,
> DerivedT>::value));
> };
>
> class B : public A<B>
> {
> };
>
> However, the static asserts still always get triggered, and I'm not
> sure why: any language lawyers understand this?

At the instantiation point B and A<B> are still incomplete.


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