
Vicente BOTET <vicente.botet <at> 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<T, char const*> convert_to<T, wchar_t const*> convert_to<T, string const&> convert_to<T, wstring const&> convert_to<T, char []> 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<bool, int> convert_to<bool, long int> convert_to<bool, short int> convert_to<bool, string-like-type> 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<bool>("false"); I vaguely remember having that issue 2-3 years back. That's why I had to split Target and Source types by convert<T>::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. :-) V.