Boost logo

Boost :

Subject: Re: [boost] [review] Conversion review ends today
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-09-01 01:47:45


On Wed, Aug 31, 2011 at 9:29 PM, Gordon Woodhull <gordon_at_[hidden]>wrote:

>
> On Aug 31, 2011, at 6:28 PM, Jeffrey Lee Hellrung, Jr. wrote:
>
> >> Jeff, what method did you use to glue together the various function
> objects
> >> into one?
> >>
> >
> > I'm not sure I understand. I have a single, well-contained family of
> > function objects that do the conversions for me, but within the context
> of
> > where these conversions are actually used, one could straightforwardly
> > replace the family of types and the corresponding family of function
> objects
> > used to effect conversions between said types.
>
> I meant, so you have a set of conversion function objects, how do you
> dispatch to the right one? Or can you just dispatch on a single type in
> your case?
>

Yeah, I always convert *to* a specific type within each function object, but
the template is parametrized on the "to" type:

template< class To >
struct convert_functor
{
    typedef To result_type;
    To operator()(const From1& from) const { ... }
    To operator()(const From2& from) const { ... }
    // etc.
};

I was hoping that there was a way to paste together a bunch of function
> objects as if they were function overloads.
>

See my other reply.

- Jeff


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