Random numbers are widely used in today’s modern applications. In C we use rand(), srand() and in C++ it is std::rand(), std::srand(). Since C++11, we can use the Mersenne Twister random generators; mt19937 (std::mt19937) for 32-bit applications and mt19937_64 (std::mt19937_64) for 64-bit applications. Modern C++ allows us to use both old and new random generators. In this post, we explain…
What Is The mt19937 Random Generator In Modern C++?
January 30, 2024
Random numbers are one of the most important parts of today’s modern programming technologies. They are used in mathematics, physics, in many engineering fields, and in programming such as generating random data for testing, random maps in levels, random trees on a…
How To Use void_t Alias Template in C++ 17?
January 25, 2024
In C++ 17, there is a very useful alias template for metaprogramming that can be used to simplify use of SFINAE. The void_tis a meta-function that is used to map any types ( or types) to typevoid. In this post, we explain what is void_t, how you can use it in…
How To Use std::invoke In C++ 17?
January 23, 2024
There is a new library feature in the C++17 standard, it is std::invoke which is a useful feature to uniformly invoke callable entities. In this post, we explain what std::invoke is and how we can use it in examples. First, let’s remind ourselves about what is a callable object and what is a functor in modern C++.
What is callable object and what is functor in modern…
Learn C++ Optimization With A Genetic Algorithms Example
January 18, 2024
Solving C++ optimization problems are one of the areas of all quantitative disciplines from social science, economics to engineering fields such as computer science. Genetic Algorithm (GA) is a kind of machine learning process that is used to generate high-quality…
What Are The Elementary String Conversions That Come With C++ 17?
January 16, 2024
In addition to many beneficial features of C++ 17, there are elementary string conversions introduced in that specification. The std::to_chars() and std::from_chars() are defined in <charconv> header to do conversions between numeric values to strings or strings to…
What Is The Class Template Variant (std::variant) in C++ 17?
January 9, 2024
In C++ Builder 12, and modern C++ the std::variant is one of the powerful features that comes with C++17. The std::variant is a discriminated union that we can work with multiple data types. It represents a type-safe union and holds one of its types in definition.
What is the class template std::variant in C++ 17?
The std::variant is a class template defined in <variant> header that…
Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. One of the great features of an object orientated language like C++ is a copy assignment operator that is used with operator= to create a new object from…
What Is The New Optional Class Template In C++ 17?
January 2, 2024
The C++17 standard came with a lot of great features and std::optional was one of the main features of today’s modern C++. std::optional<T> is a class template that is defined in the <optional> header and represents either a T value or no value. In this post…
How To Use Alias Templates For Traits In C++ 17 and Beyond
December 27, 2023
One of the great features of C++ is templates, they are parameterized by alias templates in C++11. Then, In C++14 and C++17, they improved C++11’s feature with a number of template aliases whose use simplifies the traits. This feature is called “Alias Templates For Traits” and in this post, we explain what is and alias template and how we can use alias templates with…