Boost logo

Boost :

Subject: Re: [boost] safe-bool CRTP class
From: Gregory Crosswhite (gcross_at_[hidden])
Date: 2011-05-27 13:15:21


On 5/27/11 10:08 AM, Stewart, Robert wrote:
> Krzysztof Czainski wrote:
>> That's for base class chaining to avoid multiple inheritance,
>> just like the operators library has it.
>>
>> struct X : boolable<X, addable<X> > {...};
> It's also for cases in which one would normally have this:
>
> struct derived : base
> {
> ...
> };
>
> Then, to provide safe-bool functionality for derived, one would do the following to avoid MI:
>
> struct derived : safe_bool<derived, base>
> {
> ...
> };
>
>

Okay, I think I see now. It looks to me that most of the time it really
wouldn't be a big deal at all to just add boolable<> (and addable<>
etc.) as another base class via. multiple inheritance, but I can see how
the additional flexibility is useful for times when you want to avoid
multiple inheritance in order to have the clear chain of command offered
by single inheritance.

Thank you for the explanations!

Cheers,
Greg


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