How I Improved My Legacy C++ Project With PVS-Studio

Since a few months, I've been refactoring my old C++/OpenGL project. Thus far, I used compilers (MSVC and Clang), my knowledge or free tools. At some point, I also got a chance to leverage a solid static analysis tool - PVS-Studio. The tool helped me with identifying 8 critical issues not to mention good code style and performance enhancements (in total 137 warnings)

Read on to see my report.

Lambdas: From C++11 to C++20, Part 1

Lambda expressions were one of the most powerful additions made in C++11, and they continue to evolve with each new C++ language standard. In this article, we'll go through their history and see the evolution of this crucial part of modern C++.

This article was originally posted at the author's blog: bfilipek.com

Two Lines of Code and Three C++17 Features: The Overload Pattern

While I was doing research for my book (C++17 in Detail) and blog posts about C++17, several times I stumbled upon this pattern for visitation of std::variant:

template<class... Ts> struct overload : Ts... { using Ts::operator()...; };
template<class... Ts> overload(Ts...) -> overload<Ts...>;

std::variant<int, float> intFloat { 0.0f };
std::visit(overload(
    [](const int& i) { ... },
    [](const float& f) { ... },
  ),
  intFloat;
);

With the above pattern, you can provide separate lambdas "in-place" for visitation.