Ranges in C++20

In C++20, the range concept requires that an object has both an iterator, and an end sentinel. This is useful in the context of standard collections, in particular when developing algorithms (i.e. template functions) which operate on collections. Motivation Suppose we have a vector of values which we want to sort: std::vector<int> values = {10, … Read more

Concepts in C++20

Concepts allow us to add requirements to template arguments. There are different types of constraints, e.g. Syntactic requirement – e.g. what operations need to be defined. Semantic requirements – i.e. what behaviour is required of the operations. For example, an iterator needs to have begin() and end() operations and also needs to implement the increment … Read more

Modules in C++20

C++ Modules

What are modules? Modules are the new C++20 method for importing functions and classes from external libraries and separate translational units. Modules provide an alternative to using header files. Some of the benefits of modules are: No need to write separate files for the interface (.h) and the implementation (.cpp) Faster compile / recompile times … Read more