
Boost : 
Subject: Re: [boost] [contract] toward N3351 concepts
From: Larisse Voufo (lvoufo_at_[hidden])
Date: 20121005 12:40:24
On Thu, Sep 27, 2012 at 1:21 PM, Lorenzo Caminiti <lorcaminiti_at_[hidden]>wrote:
> On Thu, Sep 27, 2012 at 7:29 AM, Andrew Sutton <asutton.list_at_[hidden]>
> wrote:
> > I'm glad to see this discussion.
>
> I'm really glad to see N3351 author(s) part of it :) BTW, do you know
> if a clangbased compiler supporting N3351 is actually being
> implemented?
>
ConceptClang is attempting to implement both the N2914 and N3351 concepts:
http://www.crest.iu.edu/projects/conceptcpp/
The website also has a link to the C++Now talk I recently gave on the
nature of concepts and
the current state of the ConceptClang implementation.
Please note that, as of now, the implementation is a work in progress.
I'm working tirelessly to make it stable soon,
while I extract theoretical findings towards completing my PhD thesis (also
soon).
Thanks,
 Larisse.
> ``
> At the same time, we plan to build a compiler (based on Clang) for the
> emerging language.
> This prototype will support the full range features described in this
> report. We hope to have an
> initial version ready by early February, 2012.
> ''
>
> Just to give a pick into a possible future of what Boost.Contract _could_
> do:
>
> // Header: boost/contract/std/concept/equality_comparable.hpp
> namespace contract { namespace std {
>
> CONTRACT_CONCEPT(
> concept (EqualityComparable) ( typename T ) (
> requires( (T) a, (T) b, (T) c ) (
> bool{a == b},
> bool{a != b},
>
> axiom( iff(a == b) eq(a, b) ),
> axiom(
> a == a,
> if(a == b) b == a,
> if(a == b and b == c) a == c
> ),
> axiom( iff(a != b) not(a == b) )
> )
> )
> )
>
> CONTRACT_CONCEPT(
> concept (EqualityComparable) ( typename T1, typename T2 ) (
> EqualityComparable<T1>,
> EuqalityComparable<T2>,
> (Common<T1, T2>),
> (EqualityComparable<CommonType<T1, T2> >),
>
> requires( (T1) a, (T2) b ) (
> bool{a == b},
> bool{b == a},
> bool{a != b},
> bool{b != a},
>
> axiom(
> typedef (CommonType<T1, T2>) C,
>
> iff(a == b) C{a} == C{b},
> iff(a != b) C{a} != C{b},
> iff(b == a) C{b} == C{a},
> iff(b != a) C{b} != C{a}
> )
> )
> )
> )
>
> } } // namespace
>
> // Header: boost/contract/std/algorithm/find.hpp
> namespace contract { namespace std {
>
> // Not fully compatible.
> CONTRACT_FUNCTION(
> template( typename I, typename T )
> requires( InputIterator<I>, (EqualityComparable<T, ValueType<I> >)
> )
> (I) (find) ( (I) first, (I) last, (T const&) value )
> ) {
> return std::find(first, last, value);
> }
>
> } } // namespace
>
> BTW, why do we declare concepts like:
>
> concept EqualityComparable< typename T > = ... // (1)
>
> Instead of:
>
> template< typename T >
> concept EqualityComparable = ... // (2)
>
> I personally prefer (2) because the template parameters are declared
> with a syntax that is more consistent with the syntax used to declare
> them in class/function templates. For similar reasons, I'd prefer {
> ... } instead of = ... for the concept definition part.
>
> Thanks.
> Lorenzo
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk