|
Boost : |
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2007-10-03 19:38:36
Tobias Schwinger <tschwinger <at> isonews2.com> writes:
>
> Emil Dotchevski wrote:
> >> I'm not keen on the use of operator<< to add the data to the exceptions.
> >
> > I do share your concern, but consider that whatever we use for boost
> > exception should support easy composition, because it needs to work
> > when used in a throw expression directly:
> >
> > throw my_error() <<
> > error_info<tag_errno>(errno) <<
> > error_info<tag_name>(name);
> >
> > Instead of << we could use .add:
> >
> > throw my_error().
> > add(error_info<tag_errno>(errno)).
> > add(error_info<tag_name>(name));
> >
> > This isn't bad, but in my opinion the << syntax is better despite my
> > strong dislike for operator overloading.
>
> Maybe a more or less obvious choice will do
>
> throw my_error() = error_info<tag>(whatever),
> error_info<another_tag>(something_else) // ...
Why not use approach similar (if not based upon) named function parameters:
throw my_error().data(( tag_errno = errno, tag_name = name, .... ))
or for exception classes with trivial forwarding temaplte constructor
throw my_error(( tag_errno = errno, tag_name = name, .... ))
I also strongly in favor boost::optional instead of pointer result type.
Gennadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk