Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-12-11 10:51:08

"Fernando Cacciola" <fernando_cacciola_at_[hidden]> writes:

> ----- Original Message -----
> From: "David Abrahams" <dave_at_[hidden]>
> To: "Boost mailing list" <boost_at_[hidden]>
> Sent: Tuesday, December 10, 2002 10:00 PM
> Subject: Re: [boost] Formal review: Optional library
>> "Fernando Cacciola" <fernando_cacciola_at_[hidden]> writes:
>> > I still don't like to think of optional<> as a container, so I still
>> > don't like this reset.
>> Do you really think of auto_ptr and shared_ptr as containers? They
>> seem to have little or nothing in common with any of the standard
>> containers.
> OK.
> After further thinking I agree that optional<> is as much as a container
> as a smart pointer -not much really-, meaning that you pass a value which
> is contained within the wrapper and which you can access it.

Unfortunately, I also agree with Peter Dimov's analysis of the ways in
which optional<> /is/ like a container. I just meant that the current
_interface_ to optional<>, auto_ptr<>, and shared_ptr<> has nothing in
common with a container's interface. Sorry to make this difficult.

>> > I'm not sure what would be effect of removing deep-constantness.
>> > It would definitely allow the leaner interface you are proposing,
>> Well, deep-constantness is utterly inconsistent with the pointer-like
>> semantics you claim to be implementing. A pointer-ish optional
>> component is a fine idea, but why not follow through all the way with
>> the idiom?
> How is deep-constantness utterly incosistent with pointer-like semantics?

    typedef T* ptr;
    T x;
    ptr const p = &x;
    T y = *p = x; // constness of p does not affect mutability of referent

If you think deep constness is important, go with a container-like
interface. Mixing idioms, especially very familiar ones, is

>> > This is a possibility.
>> > I could accept something like this, though I constantly see
>> > people complaining about lack of deep constantness on wrappers like
>> > optional<>
>> > What do others think?
>> Is it a wrapper or a pointer?
> Is a wrapper which acts partially like a pointer.

What I said before about mixing idioms, again.

                       David Abrahams
   dave_at_[hidden] *
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at, gregod at, cpdaniel at, john at