As for the
optional<TypeOut> operator()(TypeIn const&);
converter signature, then I am slowly warming up to it. If we declare something like
...
Alex, does it make you happy? Could anyone comment on that please?
It would make a lot of sense to me. However I am not sure about the
following options:
#2 void operator()(TypeIn const&, optional<TypeOut>&);
#3 optional<TypeOut> operator()(TypeIn const&);
Even though #3 looks neater, it requires explicit parameter declarations
which I find pretty ugly for operator():
#2 optional<T> out; converter(in, out);
#3 optional<T> out = converter.operator()<T>(in);
That may not be a big issue, since users are expected to use the
convert<T>::from() function.
Another advantage (that seems more substantial) of the implicit template
resolution of #2 is that the function can use template parameters other than
TypeOut and it is therefore easier to provide specializations through
overloads.
template<class TypeIn>
void operator(const TypeIn& in, optional<TypeIn>& out){...}
template