Boost logo

Boost Users :

Subject: Re: [Boost-users] exception: use of error_info can mask real exceptions
From: Andrew Venikov (andrew.venikov_at_[hidden])
Date: 2009-05-24 14:46:37

> Jon Kalb raised this issue at BoostCon. My knee-jerk reaction was that
> it makes sense to alter the specification of operator<< so it never
> throws, but now my opinion is that it isn't a good idea.

Well, in my original post I didn't mean just the inner workings of
operator<<. By the time operator<< is invoked, the temporary object
of std::string (or other type for that matter) will have to be
constructed. That means,
that the exception may be thrown before getting into operator<<

Unfortunately, it seems that using '<<' syntax it will be impossible to
catch exceptions. I hate macros as much as the next guy, but it looks
like this sort of problem is solvable only using macros.

> Consider this slightly modified example:
> std::string get_descr();
> ....
> throw f1exception() << f1_descr(get_descr());
> Even if operator<< and f1_descr's constructor never throw, in theory
> you could still get std::bad_alloc instead of f1exception.

Exactly! That's what I meant in my original post.

> Emil Dotchevski
> Reverge Studios, Inc.


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at