http://en.cppreference.com/w/cpp/language/constraints
(not part of the standard, yet)
1 2 3
|
void f(EqualityComparable&&); // declaration of a constrained function template
// template<typename T>
// void f(T&&) requires EqualityComparable<T>; // long form of the same
|
iirc: whatever object that we pass to the `f()' function must support a `==' operation, otherwise, it will generate a compile error on the form «The type is not equality comparable»
The idea seems to be to restrict what T may be, what types you may pass to the function, making sure that it would generate a compile-time error and that it would be readable.
> Does this table mean that from now on when he speaks of an "E", "C", "For" etc...
No, those names are only valid in the definition of the concepts.
In your example `N' is an int, not any kind of number (it would fail with a float)
> What is the need of "typename A = allocator<T>"
that's a default argument.
[code]std::vector<int> v; //uses std::allocator to manage the memory
std::vector<int, my_memory_pool<int> > w; //uses my_memory_pool to manage the memory
> and why does it keep repeating the concepts twice every time?
> T, typename A > T& vector<T,A
you said that your function has two templated types, but you need to say how they are used. So, T is the return type
and you are defining a member function of the class `vector<T,A>' (note that the template parameters are part of the name, vector<int> is a different type that vector<string>)