Category Archives: programming

as the name implies…

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

Operation cancelling and std::fstream

In the previous post we have sketched out the view that error handling is about expressing the success dependency between operations. I have also indicated the guideline “destructors only for releasing resources”. In this post we are going to see … Continue reading

Posted in programming | Tagged , , , | 11 Comments

Handling errors is canceling operations

I actually covered this topic before, in this post, but given my recent experience I feel it needs reiterating and a bit of restructuring. It boils down to the observation that any error handling I have encountered — be it … Continue reading

Posted in programming | Tagged , , , | 6 Comments

(Not) using namespace std;

This is called a using directive. Using it in code that is supposed to work for years is not a good idea. Sometimes programmers are given advice to just type using namespace std; and all things from the Standard Library … Continue reading

Posted in programming | Tagged | 12 Comments