Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-07-23 19:41:56


On Wed, 23 Jul 2008 16:29:14 -0700, Steven Watanabe <watanabesj_at_[hidden]>
wrote:
> AMDG
>
> Mathias Gaunard wrote:
>>> So (if I understand you correctly), you want not function-pointer
>>> behaviour,
>>> but something more like reference - have to be initialized, cannot be
> null?
>>>
>>
>> Well yeah, preventing an "empty" state means that you have to initialize
>> the thing, it cannot be null.
>> That's what the whole thread is about.
>>
>
> I don't think that boost::function should provide a never empty guarantee
> for several technical reasons:
> a) Providing the guarantee has a runtime cost. Allowing
> empty Boost.Function objects is free.
> b) Looking forward to C++0x, it is impossible to implement a
> no throw move for objects than have no empty state.
> c) Objects that provide default constructors are easier to work with.

Hi Steven,

Objects that provide strong invariants are easier to work with, too, and I
value a strong invariant far more than a default constructor. In fact, I
almost never have any use for the latter.

Point a) is compelling.

I'm not sure point b) is as absolutely true as you state it to be. I
believe there are cases where you can provide such a nothrow move. The
most obvious case is for objects that have no deep data.

Cheers,

-- 
David Abrahams
Boost Consulting, Inc.
http://www.boost-consulting.com

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