|
Boost : |
Subject: Re: [boost] [Review.Contract] Vicente's review
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-09-16 23:16:45
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 will read N3351 and check again with this ML before
making a final decision:
http://sourceforge.net/apps/trac/contractpp/ticket/96
>> static_assert(sizeof(To) >= sizeof(From), "destination too small"),
>> boost::Copyable<From>
>> )
>> (To*) memcopy ( (To*) to, (From*) from )
>> precondition(
>> to; // pointer not null
>> from; // pointer not null
>> )
>> ) {
>> // ...
>> }
Thanks,
--Lorenzo
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk