Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-26 21:44:45


On Sep 26, 2010, at 8:55 AM, Eric Niebler wrote:
>
> On 9/25/2010 1:24 PM, David Abrahams wrote:
>> On Sep 24, 2010, at 11:51 PM, Eric Niebler wrote:
>>>
>>> On 9/24/2010 9:37 PM, David Abrahams wrote:
>>>
>>> Haha! No, not at all. Let's rephrase the problem a bit. If we still had
>>> C++0x concepts, what would the concept SpiritParser look like, such that
>>> we could define spirit::qi::rule::operator= such that it required its
>>> RHS to satisfy the SpiritParser concept?
>>
>> That's easy to answer; just look at the operations that operator= et. al expect of such a type. Wouldn't SpiritParser just be some simple refinement of Callable?
>
> No. rule::operator= expects SpiritParser to be a strongly-typed tree.

Meaning? Spell it out and you have your requirements.

>>> Would it be any more
>>> illuminating that a simple wrapper around proto::matches<Expr,
>>> SpiritGrammar>?
>>
>> If you want to apply concepts to this stuff (and I'm not sure whether it's really possible), you have to go back to the classic Generic Programming Process: look at concrete algorithms, lift out common requirements, cluster into concepts, etc.
>
> Why do you doubt it's possible?

I just don't know.

> If there are template constraints not
> practically expressible in concepts, then aren't concepts broken?

Not necessarily. Concepts are not about expressing arbitrary template constraints. They're about describing abstractions. One might say that if you can't figure out how to write a concept for a template parameter, you don't understand the abstraction it's modelling.

--
Dave Abrahams
BoostPro Computing
http://boostpro.com

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