Boost logo

Boost :

From: Bjorn.Karlsson_at_[hidden]
Date: 2002-04-08 04:50:23


> From: Shane King [mailto:Shane_King_at_[hidden]]
> Why is partial template specialisation needed to achieve this ... this
> code seems to work for me (in VS6 & VS7):
>
> template <class StringType, class InitialType>
> StringType string_cast(const InitialType &initial)
> {
> std::basic_ostringstream<
> StringType::traits_type::char_type,
> StringType::traits_type,
>
>
> StringType::allocator_type> os;
> os << initial;
> return os.str();
> }
>
> Which obviates the need for the compiler to support partial template
> specialisation. Of course, PTS would be nice to allow narrow
> -> wide and
> vice versa conversions.
>

Of course, this trades partial specialization for a partial solution :) - it
works (if typename is added where appropriate) for string_cast (to_string)
only; the solution doesn't scale to cover lexical_cast (which the code from
http://lists.boost.org/MailArchives/boost/msg27288.php aimed to do).

Bjorn Karlsson



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