Tag Archives: C++20

Semantic requirements in concepts

The word ‘concept’ in the context of C++ generic programming has two meanings. The first is more abstract: it is the notion from the domain of Generic Programming (GP) in general. GP is not tied to any specific language: it … Continue reading

Posted in programming | Tagged , , , | 7 Comments

Concept archetypes — update

An observant reader indicated that in the previous post where I was trying to implement a concept archetype — a type with minimal interface that models a given concept — I actually failed. This deserves a closer examination.

Posted in programming | Tagged , , | 6 Comments

Concept archetypes

Concepts in the form added in C++20 used to be called lite. This is because they do not provide one quite important functionality: having the compiler check if the author of a constrained template is only using operations and types … Continue reading

Posted in programming | Tagged , , | 13 Comments

Ordering by constraints

In the previous post we have seen how constraint conjunction and disjunction works, and how a function template with constraints is a better match than a function template without constraints (provided that the constraints are satisfied) when determining the best … Continue reading

Posted in programming | Tagged , , , | 4 Comments

Requires-clause — updated

The previous post, “Requires-clause”, contained incorrect information about parentheses inside a requires-clause. Token || inside parentheses is still interpretted as a disjunction of two constraints. I apologize for misleading the readers. I also want to thank James Pfeffer for bringing … Continue reading

Posted in programming | Tagged , , , | 2 Comments

Requires-clause

Update. This post in its original form contained incorrect information about the meaning of parentheses inside requires-clauses in section Conjunction and Disjunction. The section has now been changed to correct this. The updated text is in blueish color. Even if … Continue reading

Posted in programming | Tagged , , , | 6 Comments

Requires-expression

This post is about a C++20 feature, so we will be talking about the future. However, this is a very near feature, C++20 is expected to go out this year, and concepts look really stable, so the chances are high … Continue reading

Posted in programming | Tagged , | 18 Comments

Short-circuiting in meta-functions

Short-circuiting in logical operations is a very useful and an often used feature: Should cond_a() evaluate to false, cond_b() is guaranteed not to be evaluated. This is useful for two reasons. One is performance: if cond_b() is an expensive operation … Continue reading

Posted in programming | Tagged , , , | 4 Comments

String literals make bad ranges

C++20 will come with what we call “Ranges” library. Meanwhile, range interface has been supported ever since C++11 in one context: range-based for loop. A range-based for loop can detect anything that is a range and work with it. In … Continue reading

Posted in programming | Tagged , , , | 2 Comments