Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-20 10:51:04

From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> From: Peter Dimov <pdimov_at_[hidden]>
> > From: "Fernando Cacciola" <fcacciola_at_[hidden]>
> > > How should we deal with the case of x,y being outside the image?
> >
> > A function should not try to do too many things.
> >
> > bool is_inside(int x, int y) const;
> > color_type get_pixel(int x, int y) const;
> >
> My point is not about returning pixels from an image. It is just an
> I'm sure you can come out with an example that suits you. (A function that
> might not return a value in a situation were that is not an exception).

I didn't mean to imply that stateful<T> is not useful. I just think that
"case A" is not a good demonstration of its usefulness, that's all.

> Or simply take the case of set/map insert().

Actually this is a bit different. The associative insert() always returns a
valid iterator, regardless of whether the 'bool' part is true. You'll have
to decide whether your class is a discriminated union (you can't extract a
value from it when it's empty(), operator* leads to undefined behaviour) or
a (T, bool) pair.

> You may think that I am solving my problems the wrong way, just like you
> with respect to the image example,

No, not at all, sorry for giving the wrong impression.

Peter Dimov
Multi Media Ltd.

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