Boost logo

Boost :

Subject: Re: [boost] Boost review of the Convert library is ongoing
From: alex (alexhighviz_at_[hidden])
Date: 2014-05-23 06:28:15


>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<class TypeIn, class A, class B>
void operator(const TypeIn& in, optional<pair<A,B> >& out){...}

template<class TypeIn, class TypeOut>
void operator(const TypeIn& in, optional<TypeOut>& out){...}


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