
on Thu Apr 09 2009, Gottlob Frege <gottlobfrege-AT-gmail.com> wrote:
Case 'C' is problematic - let's get rid of it: i = from(str, res); is difficult when the type is NOT default constructible. So let's get rid of it. If you want a status result, supply a default (case D): i = from(str, 0, res);
*Alternatively*, since we know the type, we could probably use some type-inference tricks to only allow case C to compile when the type is default constructible:
C1: int i = convert<int>::from(str, res); // OK
- compiles as int is default constructible. - does NOT throw as you get status back in res.
C2: class C { public: C(int, int); }; C c = convert<int>::from(str, res); // does NOT compile C c = convert<int>::from(str, C(1, 2), res); // default required
You might want to take a look at http://www.boost.org/doc/libs/1_38_0/libs/python/doc/v2/extract.html which had to solve some of the same problems. -- Dave Abrahams BoostPro Computing http://www.boostpro.com