Boost logo

Boost :

From: williamkempf_at_[hidden]
Date: 2001-10-08 09:19:53

--- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> From: <williamkempf_at_h...>
> > --- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> > > Arguably. Is it better to break loudly when the user does
> > > nonportable, or to understand their intention and "just work"?
> >
> > It can be argued, though, that I didn't do anything "nonportable".
> > I've included all the relevant headers according to the
> > of the standard with one viewpoint on this.
> No, I think that the standard is pretty clear here. You are
constructing a
> temporary of type std::string without including <string> first.
> > Technically I haven't
> > since I inderectly used std::string by calling the std::exception
> > type's constructor, but then we come back to wondering if the
> > of the std::exception types are broken. I *truly* don't think
> > unreasonable to expect that I shouldn't have to explicitly include
> > <string> when I construct a std::exception type if I never use
> > std::string myself. I don't really care if <exception> includes
> > <string> or not, so long as I don't have to do so myself when I
> > use std::string. There's two ways to do this right in my mind:
> > either <exception> must include <string> or all std::exception
> > need to have overloaded constructors that take const char*
> Perhaps the standard needs to be fixed (there are other reasons for
this -
> the std::string constructor may throw); the way to do this is via a
> report or an extension proposal. But currently your code does not
> A question, though: what are you trying to gain by not including
> Your code will work only if <stdexcept> does include it anyway, so
> not saving anything.
> In fact STLPort is trying to save you from including <string> if
you don't
> need it.

I don't need it. I didn't use it. That's the whole point. The fact
that the exceptions demand that you use std::string to construct them
is simply wrong. Either one or the other cases would be acceptable,
but what happens here is not.

1) I don't need <string> to construct an exception with a const
char* parameter.
2) <string> is included by <exception> because I do need it for
construction via a const char*.

The latter would be acceptable, though it causes extra dependency
overhead so the former would be preferred. This is all a technical
problem with the current definition in the standard and so STLPort is
fully conforming and I do have to include <string> myself. However,
I contend this is also a QoI issue because STLPort didn't have to
take this route in their implementation even if the standard allows

Bottom line is that I don't use std::basic_string anywhere in the
code and should not have to include <string> because there's a
dependency on it in <exception>. Either the dependency shouldn't be
there, or <exception> should include <string> itself.

Bill Kempf

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