Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-06 10:47:59

From: "Howard Hinnant" <hinnant_at_[hidden]>
> > What is the difference between the two examples? You can't add a char
> > const*
> > overload without breaking code AFAICS.
> >
> > struct X
> > {
> > operator std::string () const;
> > operator char const* () const;
> > };
> >
> > std::runtime_error(X());
> Don't they shoot programmers for doing this? :-)

They used to. :-)

> One difference is that vendors of <stdexcept> have the freedom of using
> compiler magic to make it work.
> That being said, the Metrowerks runtime_error is implemented exactly as
> you allude, and has been for several years. I've yet to receive a
> single complaint on the issue. But perhaps it is time to revisit it.
> There may be other techniques for achieving the same end. Or perhaps I
> will resort to compiler magic.

Isn't this a strong argument to fix the standard to match your

> In any event, I still think there is a valuable difference. Our
> containers (e.g. <vector>) are examples of clients who need to throw
> simple exceptions (from <stdexcept>), but don't want the overhead of
> including <string>. And if I find that desirable in my own code, it
> makes it very easy for me to imagine that others value this ability as
> well.

Don't get me wrong; I value the ability to not include <everything>. But why
not simply add the overload to the standard, instead of trying to somehow
specify that

void f(std::string const &);


is different than


when in fact the two are equivalent.

Peter Dimov
Multi Media Ltd.

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