C++11C++14C++17Learn C++Numerics

Introduction to Random Number Generation in Modern C++

Every implementation of the C++ Standard Library like one included to Embarcadero RAD Studio C++ compilers provides two ways for (pseudo-)random numbers generation: old-fashioned facilities from <cstdlib> and modern facilities provided by <random>. Facilities from <cstdlib> There are two very simple functions provided by the C random library: std::srand() and std::rand().
Read more
C++11C++14C++17IteratorsLearn C++

Range-for-statement in Modern C++

Since C++11 there are elegant way to access each element of a containers (or, more generally, sequences) – so called range-for-statement. The syntaxes are follow: template<class Container> void foo(Container& container) { for (auto element : container); // (1) for (const auto element : container); // (2) for (auto& element : container); // (3) for…
Read more
C++C++11C++14C++17IteratorsLearn C++

Reverse Iterators in C++

By using bidirectional iterator or random access iterator (see Iterator Categories in C++) it’s possible to traverse the sequence in backward direction by using operator -- or by using the special adapter template class std::reverse_iterator. But why to bother with reverse iterators if the operator -- is available for iterators with bidirectional traversing capabilities? The answer is…
Read more
C++C++11C++14C++17Language FeatureLearn C++Syntax

Unicode Strings in C++ On Windows

In programming, one of the most used variables is text strings, and they are sometimes really important when storing and retrieving valuable data. It is important to store your data safely in its language and localization. Most programming languages have issues when storing texts and letters. In C++, there is very old well-known string type (arrays of chars) and modern types…
Read more