Boost logo

Boost :

Subject: Re: [boost] [challenge!] find a common domain
From: John Bytheway (jbytheway+boost_at_[hidden])
Date: 2010-05-20 13:54:21


On 19/05/10 07:02, Eric Niebler wrote:
<snip>
> Your job: implement the deduce_domain3 template that finds the common
> domain of 3 domains. You're allowed to use decltype, but you get bonus
> points for a solution that doesn't. Bonus also for instantiating fewest
> templates. The challenge is for the ternary case, but your solution
> should scale to N domains. If your solution is better than mine, I'll
> use it in Proto and credit you!

I attach my solution for completeness, though I think Daniel's is
neater. I used a similar idea to him, but without the use of
sizeof/decltype, and with the distance-to-not_a_domain implemented as a
metafunction, rather than injected into the definition of domain.

I think we use about the same number of instantiations, but Daniel's
lends itself to unrolling much more than mine. I might argue that my
implementation is a little easier to follow than his, but it would be a
pretty feeble claim.

(Bah, if only my NNTP client had been cooperating yesterday this would
have looked a little more impressive :))

John Bytheway




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