From: Rene Rivera (grafik666_at_[hidden])
Date: 2002-07-23 21:10:08
[2002-07-24] Terje Slettebø wrote:
>>From: "Rene Rivera" <grafik666_at_[hidden]>
>>[2002-07-23] Terje Slettebø wrote:
>>>>From: "Gennaro Prota" <gennaro_prota_at_[hidden]>
>By the way, the above isn't legal code. If you dereference a null-pointer,
>you end up in the land of undefined behaviour... I see that David Abrahams
>point this out in another posting, too.
Yes I knew that ;-) I was just trying to fit it to the exact signature as
given. This might be the legal version of if: reinterpret_cast<E&>(0), but I
don't have the spec here handy to answer that definitively. Dave?
>>I wrote the equivalent but with swprintf/swscanf because I didn't want to
>>use streams :-)
>Sure, you can do that. But lexical_cast is meant to be a generic cast, so
>may be applied to any type that has stream operators. A solution with
>sprintf/sscanf or swprintf/swscanf will only be able to handle the types
>write it to handle. If you want to extend it to handle more types, you have
>to change the code. You don't have to do that with lexical_cast. Also,
>streams means it also uses the currently set locale, to handle the
>formatting. This is something that the C functions won't do.
Yep, correct on both counts, and two issues that I don't deal with because I
deal with program generated and parsed data. No humans involved to conform
to their wishes :-)
>Why wouldn't you want to use streams? Efficiency? In that case, have you
>measured the difference? Bjarne Stroustrup did some measurements with
>various implementations, comparing C I/O with streams, and found that
>sometimes, the stream version was faster, and sometimes, the C I/O version
>was faster. So clearly, it's possible to write a stream implementation that
>is as least as fast as the C I/O version.
Nope not speed efficiency, memory efficiency, draging in the streams code is
just something that I try to avoid in server, or low memory programs. The
less memory I use on the server the more threads and clients I can handle.
-- grafik - Don't Assume Anything
-- rrivera_at_[hidden] - grafik_at_[hidden]
-- 102708583_at_icq - Grafik666_at_AIM - Grafik_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk