Implementation Challenge: Concepts in C++14
There is the concept TS, a technical specification for including concepts into C++17. Concepts have always been a … concept in C++. They are used to document constraints on template parameters. For example:
template <typename RandomAccessIterator, typename Comperator>
void sort(RandomAccessIterator begin, RandomAccessIterator end, Comperator comp);
This function has the requirement that begin
and end
are both random access iterators and comp
is a comparison function.
Right now, the concepts are only documented and ignoring them leads to great error messages.
The concept TS provides ways to embed them in the language directly and make, for example, overloading based on the concept easier.
But it doesn’t really bring anything new to the language. Everything it does can be accomplished with C++11’s expression SFINAE today, it only brings an (arguably) cleaner syntax and more complexity to the language.
In this post I’ll show you how to do implement concepts using only C++14 language features. I’ll try to make it as easy as possible by introducing some library utilities you can use very easily.
» read more »