From: David Abrahams (dave_at_[hidden])
Date: 2003-03-22 13:26:26
Terje Slettebø <tslettebo_at_[hidden]> writes:
>> >> > As it stands, it prints "Exception - Constructor", as it throws
>> >> > an exception in the constructor of the Exception exception. If
>> >> > the throw-statement in the constructor is commented out, it
>> >> > prints "Exception - Exception", apparently not invoking the copy
>> >> > constructor when throwing the exception (which it's allowed to).
>> >> Irrelevant. A program that invokes undefined behavior may appear to
>> >> work fine also.
> I did not state the latter part as a general claim, which is why I said that
> eliding the copy is something it's allowed to, but not required to. Thus,
> there's no argument to consider "irrelevant".
What I meant (though sorry I was probably too blunt about it) was that
it's irrelevant whether you actually observed termination or not,
unless you're intending for lexical_cast to work just on that compiler.
>> Just use a string literal; the compiler has to allocate that as part
>> of the program image.
> Sure, that's what the original lexical_cast did. However, if you are to
> include in the string info about the types, storing it as a string literal
> is not enough.
No, but you could store 3 char const*s, using type_info::name() for
two of them.
>> > The reason the extended error type was added, was that there has
>> > been requests on this list for storing the types used in the
>> > conversion, in the exception, to make it easier to know which
>> > conversion failed.
>> That's a good request, but you didn't do that, did you?
> Let me rephrase it: IIRC, the request was for storing information about the
> types used, not how this was to be done. Thus, whether or not this does what
> was requested depends on how to interpret the request.
> The suggestion to store (pointer/reference to) type_info objects doesn't
> store the types, either; it stores information about them, this time in a
> way easier for the program to use.
> So, I can just as well say as you say: The suggestion you said you meant
> (storing references to type_info objects) doesn't do that, either, does it?
Ugh. As far as it's possible to store a type at all in C++, yes my
suggestion does store the types.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk