Boost logo

Boost :

Subject: Re: [boost] [lexical_cast] A suggestion
From: Vladimir.Batov_at_[hidden]
Date: 2009-02-08 15:44:49

> That's not my concern. My concern is that I don't think lexical_cast is
> a particularly good interface for its main uses, which could be thought
> of as "to-string" and "from-string."

Dave, I am not sure what you see wrong with lexical_cast interface. Could
you elaborate? I am not using lexical_cast (due to throw, no default value
and the def.ctor requirement). So, I still keep using the analog I wrote a
while back and well before I ever heard of lexical_cast. Even though I
wrote it independently, the interface happened to be very close:

namespace aux
        namespace string
                template<class Type> std::string from (Type const&);
                template<class Type, class String> bool is (String const&)
                template<class Type, class String> Type to (String
                template<class Type, class String> Type to (String const&,
Type const&);

That is,

        string str = aux::string::from(-1);
        int i1 = aux::string::to<int>(str); // throw
        int i2 = aux::string::to<int>(str, -1); // no throw

As you can see it is pretty close to lexical_cast.

> ...
> I just don't think lexical_cast is the interface we need for most
> convenient string conversions.

It might be the case. However, I do not see any other practical
suggestions that we could act on. Therefore, in the end we end up with
nothing at all... again. That's been dragging for far too long.
> ...
> Maybe so, but I don't think lexical_cast is all that well-designed for
> convenience to begin with, and tacking on little convenience features
> isn't likely to yield a very clean interface.

I am not that concerned about the internal design as it can be worked on
and improved without rush behind the interface. If it is the interface
that is the issue, then let's look at it. Any suggestions? So far, I do
not see people arguing against that proposed "extension" offering anything
practical in return. That is not constructive as people end up with
nothing at all.

I am not counting the <optional> suggestion as it seems as an overkill and
it still has the default-constructability requirement.


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