|
Boost : |
Subject: Re: [boost] [Review.Contract] Vicente's review
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2012-09-04 11:33:56
>
> 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
> )
> requires( // included in the function body
> 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
> )
> ) {
> // ...
> }
>
We (or I) are too much used to "requires" implying concepts, implying
enable-if behavior. So I would find this one confusing. Although the "if"
makes sense. One other alternative would be:
keyword "enable_if" -- for soft conditions
keyword "expect" or "check" -- for hard conditions
But your first suggestion is satisfactory.
Regards,
&rzej
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk