Boost logo

Boost :

Subject: Re: [boost] [challenge!] find a common domain
From: Marco (mrcekets_at_[hidden])
Date: 2010-05-19 17:08:22


I am a bit surprised by:

// These should be ambiguous.
     BOOST_MPL_ASSERT((is_same<deduce_domain3<DD1, DD0, DD0>::type,
not_a_domain>));
     BOOST_MPL_ASSERT((is_same<deduce_domain3<DD0, DD1, DD0>::type,
not_a_domain>));
     BOOST_MPL_ASSERT((is_same<deduce_domain3<DD0, DD0, DD1>::type,
not_a_domain>));

I was expecting something like:
BOOST_MPL_ASSERT((is_same<deduce_domain3<DD1, DD0, DD0>::type,
default_domain));

Am I missing something ?

-- Marco Cecchetti

On Wed, 19 May 2010 08:02:56 +0200, Eric Niebler <eric_at_[hidden]> wrote:

> I recently solved a devilish C++ coding problem related to the new
> sub-domain feature of Proto. I don't care for my solution, so I thought
> I'd throw it out there and see if some smart person could do better. I'm
> sending along the skeleton of the solution and some tests that it needs
> to satisfy. The rest is up to you.
>
> The problem goes like this. Every Proto expression has a "domain", which
> is a type defined something like this:
>
> struct my_domain : domain<> {};
>
> A domain can be a sub-domain of another domain, defined like this:
>
> struct my_sub_domain : domain<my_domain> {};
>
> When combining sub-expressions into larger expressions, the new
> expression has some domain that depends on the domains of its children.
> This domain is calculated according to some rules.
>
> - Domains that share no common super-domain are incompatible with each
> other. The result should be not_a_domain.
> - A sub-domain is "stronger" than its super-domain.
> - For a set of domains, the common domain is the strongest domain that
> is a super-domain of every domain in the set.
> - default_domain is special; it is compatible with (and dominated by)
> all other domains.
> - A sub-domain of default_domain is stronger than default_domain and
> still compatible with and dominated by all other domains.
>
> 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!
>
> Good luck.
>
> P.S. I haven't checked my solution in yet, so you can't look in trunk
> and cheat. ;-)
>

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

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