Boost logo

Boost :

Subject: Re: [boost] [Review.Contract] Vicente's review
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-09-17 13:06:01


on Sun Sep 16 2012, Lorenzo Caminiti <lorcaminiti-AT-gmail.com> wrote:

> On Sun, Sep 16, 2012 at 6:27 PM, Dave Abrahams <dave_at_[hidden]> wrote:
>>
>> on Tue Sep 04 2012, Lorenzo Caminiti <lorcaminiti-AT-gmail.com> wrote:
>>
>>> Just to consider all alternatives, we could also do this:
>>>
>
>>> CONTRACT_FUNCTION(
>>> template( typename To, typename From )
>>> if( // used with enable_if in the declaration part
>>> is_convertible<From, To>::value,
>>> is_convertible<To, From>::value
>>> )
>>
>> +1 for "if." Andrzej's "enable_if" suggestion is nice and more explicit
>> too, but there's no syntax highlighting bonus. I'm torn.
>>
>>> requires( // included in the function body
>>
>> The fact that this is "included in the function body" is irrelevant I
>> think. I guess the real point you're trying to make is that it
>> generates hard errors at acompile time when violated. That suggests
>> something like "asserts" instead of "requires."
>
> Then I think "check" for hard errors and "requires" for SFINAE is a
> good choice (requires better than if or enable_if for SFINAE I
> think...).

I don't see what justifies any of those conclusions. Neither "check"
nor "requires" particularly implies hard errors or SFINAE. enable_if
does, even if you don't know what SFINAE is.

-- 
Dave Abrahams
BoostPro Computing                  Software Development        Training
http://www.boostpro.com             Clang/LLVM/EDG Compilers  C++  Boost

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