Concepts will make algorithms more flexible.
•People always ask why we don’t overload
algorithms with versions that take a whole container, instead of a [begin,end) range. Answer: Without concepts, the
overloads conflict.
• template<class T>
void
sort( RandomAccessIterator<T> first, RandomAccessIterator<T> last );
• template<class T>
void
sort( RandomAccessIterator<T> first, RandomAccessIterator<T> last,
BinaryPredicate<T,T> pred );
• template<class T>
void
sort( Container<T> &c );
• template<class T> //
without concepts, this one conflicts with the first
void
sort( Container<T> &c, BinaryPredicate<T,T> pred );
•To sort a whole container, today we
write:
• sort( v.begin(), v.end()
);
•With the above, we could write
just:
•
sort( v );