|
Boost : |
Subject: Re: [boost] [review] string convert
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-12 16:38:07
> Message du 12/05/11 00:21
> De : "Vladimir Batov"
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] [review] string convert
>
> > Vicente BOTET wanadoo.fr> writes:
> >
> > ... and second partial template specialization of a convert_to functor (with
> > two type template parameters Target and Source) ...
> >
> > The library contains a lot of examples of partial specializations as for
> > example the optional
> > conversions. I have added a dummy complete specialization for std::string,
> > bool and everything is OK.
>
> The problem: there may be two independent specialization streams -- by the
> Source type and by the Target type. For example,
>
> convert_to
> convert_to
> convert_to
> convert_to
> convert_to
>
> string-to-type share the same implementation of a partial specialization for the
> Source type -- a string-like type. Then, one wants to specialize/optimize by the
> Target type. Say, specifically for bool and tries to provide
>
> convert_to
> convert_to
> convert_to
> convert_to
>
> The latter bool-to-string-like-type is a partial specialization again as it
> takes any string-like type (char const*, std::string, etc.).
>
> Now type-to-string and bool-to-string partial specializations seem to
> match/clash for
>
> bool v = convert_to("false");
>
> I vaguely remember having that issue 2-3 years back. That's why I had to split
> Target and Source types by convert::from(S).
>
> I did look at your examples/tests in the conversion/libs/test directory. They
> all seem to be complete specializations for a particular Target type. The
> std/string.hpp does not cover the above-mentioned use-case as it deals with
> type-to-std::string (again specialization by Target type) conversion. That is, I
> did not find any specializations by the Source type like any-string-to-type
> conversion tests/examples. That might be the reason you have not had the problem
> that I described. :-)
As I said
> > I have added a dummy complete specialization for std::string,
> > bool and everything is OK.
I have committed the added changes so you can play with, even if it is not useful for the library as the behavior is not specialized. You can update the sandbox now to check and play with.
Best,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk