Boost logo

Boost :

Subject: Re: [boost] [contract] static assertions
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-05-16 08:40:07


On Sat, May 15, 2010 at 8:50 PM, vicente.botet <vicente.botet_at_[hidden]> wrote:
> ----- Original Message -----
> From: "Lorenzo Caminiti" <lorcaminiti_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Thursday, May 13, 2010 10:32 PM
> Subject: Re: [boost] [contract] static assertions
>
>
>>
>> On Thu, May 13, 2010 at 4:24 PM, Thorsten Ottosen <nesotto_at_[hidden]> wrote:
>>> Lorenzo Caminiti skrev:
>>>> Shall Boost.Contract static static assertions?
>>>>
>>>> 1) N1962 removed static assertions previously added by revisions N1866
>>>> and N1773 of the same proposal -- why?
>>>
>>> static_assert was added to the language.
>>
>> Makes sense.
>>
>> Do you think it would be valuable for my library to support static assertions?
>
> If what you want is a uniform way you could always forward to the Boost.StaticAssert library. Boost.Mpl provide also some interesting variants that could also be forwarded.

Yes, I have implemented this in the past couple of days. Something
like `(precondition)( (static)(boost::is_const<T>) )` expands using
`BOOST_MPL_ASSERT_MSG()` and it works quite nicely.

Now that I have implemented Boost.ConceptCheck and Boost.Parameter
support within Boost.Contract, there are quite a few ways to check
static conditions:
1) Boost.ConceptCheck concepts -- as usual at the template parameter level.
2) Boost.Parameter parameter type requirements -- as usual at the
function parameter level.
3) Boost.Contract static assertions -- at the
precondition/postcondition/class-invariant level.
Even if all these checks evaluate at compile-time, they are all
semantically different. I will make sure to document them and provide
examples.

Thanks.

-- 
Lorenzo

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