Boost logo

Boost :

From: Oleg Abrosimov (beholder_at_[hidden])
Date: 2006-05-05 11:06:10

Alexander Nasonov:
> Jeff Garland wrote:
>> Oleg Abrosimov wrote:
>>> and if one wants to be very modern ;-) but doesn't concern about
>>> symmetry in from_string/string_from usage :
>>> double d = 2 + from_string<double>("10.2");
>> This is fine too. Perfect symmetry isn't really needed.
> I agree with Jeff.
> The string_from differs from the from_string in a fundamenal way: the
> former _accepts_ arguments of different types while the latter _returns_
> different types. You can't overload on return types in C++.
> Why do you require a symmetry for asymmetrical functions?

in the "Lexical Conversion Library Proposal for TR2" (N1973) proposal
Kevlin Henney and Beman Dawes states:

"Since either the source or target are usually strings, why not provide
separate to_string(x) and string_to<t>(x) functions?

The source or target isn't always a string. Furthermore, the from/to
idea cannot be expressed in a simple and consistent form. The illusion
is that they are easier than lexical_cast because of the name. This is
theory. The practice is that the two forms, although similarly and
symmetrically named, are not at all similar in use: one requires
explicit provision of a template parameter and the other not. This is a
simple usability pitfall that is guaranteed to catch experienced and
inexperienced users alike -- the only difference being that the
experienced user will know what to do with the error message."

for me it is reasonable enough to require a symmetric usage of
from_string/string_from functions I've proposed.

Oleg Abrosimov.

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