C ++ concept example from "Simplify the use of concepts"

I read the Bjarne Stroustrup mini-paper, β€œSimplifying the Use of Concepts,” and I came across the following snippet (page 9), which I reproduce below:

concept ABx<typename T> {
   void a(T&);
   void b(T&);
};
concept Ax<typename T> {
   void a(T&);
};

Obviously, every type that a is ABxalso Ax, therefore:

template<Ax T> void f(T);
template<ABx T> void f(T t);
void h(X x) // X is a type for which a(x) is valid
{
    f(x); // ambiguous
}

In other words, in the general case, we must protect against ACxs [sic] a()other than Axs a(). If the two a()can be different, we cannot accept the challenge g(t)above, because it will cause "wrong a()."

I find it difficult to understand this example; in particular, I do not understand the discussion at the end.

  • Does Bjarne mean ABx, not ACx? (Where am I marked [sic])
  • , X , a(x) b(x) ? a(x), , template<ABx T> void f(T t); , .
  • , Bjarne, , a() . ?

, , ++. , - .

+4

Source: https://habr.com/ru/post/1598469/


All Articles