|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-10 12:51:34
From: "Douglas Gregor" <gregod_at_[hidden]>
> On Wednesday 10 October 2001 10:55, you wrote:
> > A problem with the precise definition of such a cast is when is the
> > returned pointer/reference invalidated.
>
> I would think we'd follow the lead of the std containers here: don't
specify
> in the cast function itself when the pointer/refefence is invalidated, but
> instead specify in the documentation of the variant-like type when
references
> can be invalidated. For instance, std::vector<T, A>::begin() doesn't
specify
> when the iterator becomes invalid, but std::vector<T, A>::reserve()
specifies
> that it may invalidate all pointers, references, and iterators to
contained
> data.
Sounds good, although I'd like to hear Kevlin Henney's opinion on this.
> // Only needed for some broken compilers
> friend safe_bool operator!(const T& t)
> { return make_safe_bool(!((bool)t)); }
The only comment I have is that operator! should probably return a real
bool, as it would without the workaround (given a conforming compiler.)
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk