|
Boost : |
Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-28 21:14:59
At Tue, 28 Sep 2010 15:36:30 -0400,
Daniel Walker wrote:
>
> >> Was there something unsatisfying about the solution I posted in
> >> http://permalink.gmane.org/gmane.comp.lib.boost.devel/209012 ?
> >
> > Nope, I just missed it.
>
> Oh wait! I think I have another example that's more truthy. :) I'll
> use Boost.ConceptCheck to flesh it out. Let's define the concept of an
> AdditivePair to represent the arguments to binary addition. To model
> the concept a type needs to support first(x), second(x) and add(x) for
> an object x where all three functions have integer values.
<snip>
> We can now adapt std::pair<int,int> to model the AdditivePair concept.
>
<snip>
> And we can also adapt int to model the AdditivePair concept; i.e. int
> is an additive pair where the second member is 0.
<snip>
> That seems pretty natural to me.
Do you honestly think it's as truthy as the solution I offered?
IMO it's a slight improvement over the list's previous offering, but
making int model AdditivePair is still an odd contortion.
AdditivePair still doesn't represent a real abstraction that you'd use
anywhere else. By contrast, you could make int model ComplexNumber;
that would make real sense and be useful outside of this toy problem.
Are you just exploring, or is there another reason we keep heading
down this path?
-- Dave Abrahams BoostPro Computing http://www.boostpro.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk