Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2000-12-04 10:09:43


> Yes, but what would work? I don't see a way to allow
>
> lexical_cast< double >( "0.123" );
>
> other than specializing lexical_cast and this in turn requires
> declaring lexical_cast as
>
> ...( S arg ) instead of ...( const S& arg )

template<class T, class S> struct lexical_cast_helper
{
    T call(S const & s); // original definition goes here
};

template<class T, class S> T lexical_cast(S const& s)
{
    return lexical_cast_helper<T, S>::call(s);
}

Now you can partially specialize lexical_cast_helper<T, S>.

--
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