
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