From: Kevlin Henney (kevlin_at_[hidden])
Date: 2000-12-01 08:55:00
In message <90876s+i8vd_at_[hidden]>, d.frey_at_[hidden] writes
>I think I found out why the old version used 'S arg' instead of 'const
>S& arg'. I tried to specialize lexical_cast. I failed to specialize
>for T == S, I managed to specialize lexical_cast< string, string > and
>I managed to specialize lexical_cast< string, const char* > but I had
>to replace 'const S& arg' by 'S arg' to make the last one work. Here's
>/* How to specialize for T == S ???
>template< typename U > template<> U lexical_cast< U, U >( U arg )
> cout << "X.";
> return arg;
Requires partial function template specialisation, which we don't have
in the language. You can overload but not specialise.
>// This only work for lexical_cast's argument being declared as 'S
>arg' and not 'const S& arg'
>template<> string lexical_cast< string, const char* >( const char* arg
> cout << "3.";
> return string( arg );
Did you also try this with const char *& rather than plain const char *?
Kevlin Henney phone: +44 117 942 2990
Curbralan Limited mobile: +44 7801 073 508
mailto:kevlin_at_[hidden] fax: +44 870 052 2289
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk