$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Yuval Ronen (ronen_yuval_at_[hidden])
Date: 2005-01-30 16:20:41
> Come to think of it, it can be done simpler and clearer, and avoiding any
> extra includes, like this:
> 
>     namespace detail
>     {
>         template<class T>
>         struct array_to_pointer_decay
>         {
>             typedef T type;
>         };
> 
>         template<class T, size_t N>
>         struct array_to_pointer_decay<T[N]>
>         {
>             typedef const T * type;
>         };
>     }
> 
>     template<typename Target, typename Source>
>     Target lexical_cast(const Source &arg)
>     {
>         typedef typename detail::array_to_pointer_decay<Source>::type
> NewSource;
> 
>         detail::lexical_stream<Target, NewSource> interpreter;
>         Target result;
> 
>         if(!(interpreter << arg && interpreter >> result))
>             throw_exception(bad_lexical_cast(typeid(NewSource),
> typeid(Target)));
>         return result;
>     }
I haven't tried it, but I have a feeling that it will work for string 
literals, but not for c-string variables, so another specialization 
might be needed. But it shouldn't be too hard to add, so no real problem 
here. Or maybe c-string variables aren't supposed to be supported anyway?
> This requires support for partial specialisation, but so does remove_bounds
> used in the first suggestion, so it doesn't change the compiler
> requirements. Besides, the current version of lexical_cast in CVS doesn't
> work with MSVC 6, anyway. Of course, if this was very important, I guess it
> would be possible to fall back to pass by value for MSVC 6, and possibly fix
> other problems with it. I also see that MSVC 6 is no longer part of the
> Boost regression test.
Do you mean that boost has finally dropped support for MSVC 6? 
Congratulations, it's about time... :-) Anyway, the above solution looks 
excellent to me.