Subject: Re: [boost] [contract] toward N3351 concepts
From: Andrew Sutton (asutton.list_at_[hidden])
Date: 2012-10-02 11:07:32


> However, syntactically you use it similarly to a template:
>
> MyConcept<T1, T2, T3>
>
> my_template<T1, T2, T3>

Syntactically yes, but they are allowed to mean very different things.

>> concept <typename T> EqualityComparable = ... // (3)
>
> Actually, this would make the most sense to me, why wouldn't we use
> this syntax (3)?

Alex wanted the syntax to reflect, to some extent, the style that he
used to define concepts in Elements of Programming. A concept is a
type predicate (function) defined by a conjunction of syntactic and
semantic requirements. Compare:

// EoP (with pseudo-C++ syntax)
Relation(Op) =
       Predicate(Op)
  && HomogeneousFunction(Op)
  && Arity(Op) == 2

// N3351
concept Relation<typename Op, typename T> =
  Predicate<Op, T, T>;

In the writing, we wanted to emphasize the idea that a concept was
"just" a predicate on template arguments. That made it easier to focus
on the algorithm's requirements rather than to figure out the
extensive set of language rules that would make it work.