C++C++17C++20Learn C++Templates

How To Use std::invoke In C++ 17?

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…
Read more
C++C++17Learn C++Syntax

What Is The New std::sample Algorithm In C++ 17?

The C++ 17 standard bring us a lot of useful methods, templates and algorithms. One of the great algorithms is std::sample defined in the <algorithm> header that samples at most n elements uniformly from a given range. In this post, we explain the std::sample algorithm and how we can use it with an mt19937 random generator. What is the std::sample algorithm in C++ 17 and beyond? The…
Read more
C++C++17C++20Learn C++

What Is The New Optional Class Template In C++ 17?

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, we explain, what is optional in modern C++ and how we can use it efficiently. What is the optional class template in C++ 17…
Read more
C++C++17C++20Introduction to C++IteratorsLearn C++Syntax

What Is basic_string_view And string_view In Modern C++

C++17 had enormous changes in C++ features. One of them was basic_string_view (std::basic_string_view) which is a constant string container that can be used for multiple string declarations. The basic_string_view is a modern way of read-only text definition. It can be used by iterators and other methods of the basic_string_view class. In this post, we explain basic_string_view and its…
Read more