Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Fabio Fracassi (f.fracassi_at_[hidden])
Date: 2012-06-23 06:39:07


On 6/22/12 10:17 PM, Robert Ramey wrote:

> BUT - now you've sucked me into looking at the merits of including it, I
> don't
> see that it would be of any use. here's typical serialization code:
>
> #include <boost/archiive/binary_iarchive.hpp>
> #include <ifstream>
> ....
> f(...){
> ifsteam is("my file")
> binary_iarchive ia(is);
> try {
> my_data d;
> ia >> d;
> }
> catch(boost::archive::exception ae){
> std::cout << ae.what();
> throw(ae) ; // or throw something else
> }
> return;
> }
>

Well my typical code looks more like

load(...) {
   ifstream is("myfile");
   binary_iarchive ia(is);
   my_data d;
   ia >> d;

   return;
}

with the first try block "miles" away from the call. With a whole lot of
layers in between. Layers which may or may not invoke threads.

The use you don't see is that I can do this. By not using boost
exception you force me to take extra care either everywhere I use
serialization or everywhere I use threads.
Its not much work, but it still inhibits a much cleaner abstraction level.

regards

Fabio


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