Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-02-10 02:52:36


"Geoff Leyland" <gley001_at_[hidden]> wrote in message
news:E94BA576-5B96-11D8-B48C-000A95DB9BF6_at_ec.auckland.ac.nz...
> On 10/02/2004, at 6:54 PM, Jonathan Turkanis wrote:
>
> > I think boost should encourage best practices, not practices which
> > work acceptably only in limited circumstances without providing
> > substantial benefits.
>
> Fair call.
>
> > For miscellaneous errors, you can use one the
> > standard exception classes, such as runtime_error, using a
> > stringstream to format the results, if you like:
> >
> > stringstream s;
> > s << "somebody made " << x << " mistakes";
> > throw runtime_error(s.str());
> >
> > This gives you the results you want, doesn't it? Is it really that
> > inconvenient?
>
> Oh, well I'm alright, because I'll go on using my streamy exception
> where I think it's warranted.

No objection here.

>
> Convenience is an interesting question though. To some extent (no
> offence to the authors of excellent libraries that I use a lot and
am
> extremely grateful for) my use of boost::lambda and boost::bind
amounts
> to avoiding the inconvenience of hand writing function objects
<snip>

That's what they're for. I like convenience too. ;-)

>
> Funny that gcc's runtime_error uses a string copy constructor that
> could potentially throw :-)
>

True, using the standard exception classes does not necessarily
address all the issues discussed in the guidelines. I haven't studied
the libstdc++ string class in detail, but I think it's a reference
counted string whose copy constructor shouldn't throw in the
circumstances we've discussed. Other libraries (Dinkumware, I think)
definitely have this problem.

Jonathan


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