Boost logo

Boost :

Subject: Re: [boost] [guidelines] why template errors suck
From: David Abrahams (dave_at_[hidden])
Date: 2010-09-27 12:56:16


On Sep 27, 2010, at 9:51 AM, Andrew Sutton wrote:
>
>>
>>>> I was never convinced that valid expressions are the wrong
>>>> approach.
>>
>>> To convince yourself:
>>>
>>> * Write down the find_if algorithm in a natural way
>>> * write down the valid expressions implied by that algorithm
>>> * now re-check the algorithm against the valid expressions
>>
>> So, no takers? :-)
>>
>>
> I'm not sure I fully understand the problem.

Of course not; you didn't try it! ;-)

> Surely, you can use the
> Concept_check library to describe constraints for the find_if algorithm, and
> the Concept_check library internally validates those constraints against
> expressions expected to be valid. To me, that would imply that valid
> expressions can be used to describe constraints.
>
> Am I missing something?

Among other things, you're missing the other half of concept checking: checking algorithm bodies against constraints (which is done in the Concept_check library by using archetypes).

P.S. I'm not claiming concepts can't be described via valid expressions; I'm claiming it's the wrong approach, for reasons that should become evident to anyone who *actually does the exercise*.

--
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