Boost logo

Boost :

From: d.frey_at_[hidden]
Date: 2000-12-04 08:57:00


--- In boost_at_[hidden], "Peter Dimov" <pdimov_at_m...> wrote:
> Write it with the const on the right:
>
> template< typename T, typename S > T lexical_cast( S const & arg );
>
> template<> string lexical_cast< string, char* >( char const * & arg
);
>
> Now it is clear that the declarations don't match. You'd need
>
> template<> string lexical_cast< string, char const * >( char const *
const &
> arg );
>
> but this wouldn't work either, because
>
> lexical_cast<int>("Hello")
>
> is actually
>
> lexical_cast<int, char const (&) [6]>("Hello").

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 )

Regards, Daniel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk