Boost logo

Boost :

Subject: Re: [boost] [contract] toward N3351 concepts
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2012-10-09 08:50:29


On Mon, Oct 8, 2012 at 10:34 PM, Nathan Ridge <zeratul976_at_[hidden]> wrote:
>
>> Or what mechanism should be used to allow types which fulfil axioms only
>> partly? axiom_cast<double,TotallyOrdered> ?
>
> I would prefer something like this - explicitly overriding axiom-checking
> in the few cases where this would need to be done - over losing the
> benefits of the compiler checking the axioms in cases where it can (which
> are probably also few, but they exist).

Maybe we could use the difference between bound variables and unbound
to say what can be checked:

template <typename Iterator, typename T>
void find(Iterator first, Iterator last, T value)
{
  axiom { x::T. x == x }
  [ ... ]
}

Would allow the compiler to check all values the function find sees. So,
all values in [first, last) and value.

And:

template <typename Iterator, typename T>
void find(Iterator first, Iterator last, T value)
{
  axiom { /\x in T. x == x }
  [ ... ]
}

The compiler can check all values in T, so it could show that double violates
this because NaNs don't compare equal to itself.

Just a thought.

> Regards,
> Nate

Regards,

-- 
Felipe Magno de Almeida

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