|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-05 06:48:07
From: <williamkempf_at_[hidden]>
> --- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> > Arguably. Is it better to break loudly when the user does something
> > 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 requirements
> 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 design
> of the std::exception types are broken. I *truly* don't think it's
> 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 never
> use std::string. There's two ways to do this right in my mind:
> either <exception> must include <string> or all std::exception types
> need to have overloaded constructors that take const char* parameters.
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 defect
report or an extension proposal. But currently your code does not conform.
A question, though: what are you trying to gain by not including <string>?
Your code will work only if <stdexcept> does include it anyway, so you're
not saving anything.
In fact STLPort is trying to save you from including <string> if you don't
need it.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk