Boost logo

Boost :

Subject: Re: [boost] [contract] static_assert in contracts or not?
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2012-09-16 23:26:57


On Sun, Sep 16, 2012 at 6:31 PM, Dave Abrahams <dave_at_[hidden]> wrote:
>
> on Mon Sep 03 2012, Andrzej Krzemienski <akrzemi1-AT-gmail.com> wrote:
>
>> I do not know if Boost.ConceptCheck offers the capability of verifying any
>> boolean predicate.
>
> Sure; even if the concept isn't already in the library, you can easily
> write it.

So if we can program a static boolean predicate then we can program a
ConceptCheck concept that will statically assert it and make it fail
at compile-time. I guess however that the opposite is not true. There
are conditions that can be programmed to generate a hard compiler
failure (e.g., using ConceptCheck) but we cannot create a boolean
meta-function for them (e.g., to use enable-if and/or SFINAE-like
concepts).

For example we can program CopyConstructible but we cannot program
has_copy_constructor--am I correct? Is that true with C++11 expression
SFINAE as well?

If that is the case, there can be type requirements that we can only
program using hard-failing-concepts (ConceptCheck concepts within
Contract's check clause) but not using SFINAE-concepts (possible
future Boost.Contract's requires clause).

Thanks,
--Lorenzo


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