The ranges library in C++20 supports sentinels. Sentinels stand for the end of a range and can be regarded as generalized end iterators.
Concepts are a powerful and elegant tool to check at compile time if a type fulfills. Thanks to static_assert, you can use concepts as a standalone feature: static_assert(Concept<T>).
static_assert allows you to check at compile time if a type T fulfills the Concept: static_assert(Concept<T>).
In my last post "Defining Concepts with Requires Expressions", I exemplified how you can use requires expressions to define concepts. Requires expressions can also be used as a standalone feature when a compile-time predicate is required.
In my last post, "Define Concepts", I defined the concepts Integral, SignedIntegral, and UnsigendIntegral using logical combinations of existing concepts and compile-time predicates. Today, I use Requires Expressions to define concepts.
There are two ways to define a concept: You can combine existing concepts and compile-time predicates, or you can apply a requires expression in four different ways.
In my last post, I presented a possible std::advance implementation based on tag dispatching. One of my readers mentioned that I could also implement std::advance based on constexpr if, or concepts. His right. So let's do it.
I started my discussion about the "Automatic Return Type (C++98)" in my last post. Today, I'm faced with the same challenge but solve it with C++11, C++14, and C++20.
In the last post, "Function Templates", I wrote about the overloading of function templates and automatically deducing the return type of a function template. Today, I dive deeper and explicitly specify a function template's arguments and bring concepts into the play.
Let me conclude my series to concepts with this meta-post. Are concepts an evolution or a revolution in C++? The answer to this question bothered me quite a time.
Hunting
Today 3870
Yesterday 4344
Week 40748
Month 20994
All 12099203
Currently are 155 guests and no members online
Kubik-Rubik Joomla! Extensions
Read more...
Read more...