
On 5/19/2010 3:29 PM, Daniel Wallin wrote:
On Tue, May 18, 2010 at 11:02:56PM -0700, Eric Niebler wrote:
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.
Here's mine. It's decltype based, but I guess it could be sizeof based in C++03.
Wow! SO much simpler than my solution. I'll need to study this in depth. I also specialized domain<default_domain> to insert an extra level in the inheritance tree like you did. That's a great simplification, but it took me a week to see that. Kudos. BTW, you're creating a zero-sized array in sized_type<0>. I just bumped all the integers by one and it works fine on msvc-10. This looks more efficient at compile-time, too. I'll be embarrassed to post my solution. :-O But not yet. Anybody care to eliminate decltype so I can use this in Proto? Anybody think they can instantiate fewer templates? (I think everybody who posts a solution will get a mention in Proto's docs and in the code. Fair's fair.) -- Eric Niebler BoostPro Computing http://www.boostpro.com