![](https://1.bp.blogspot.com/-gPp3qoA4Dk4/X15tUnICdrI/AAAAAAAAEvo/kjVZvvjehmogIFnmFx6QF9CitcKHwVqiQCLcBGAsYHQ/s0/pvschecking.png)
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.
Replacing Unique_ptr With C++17’s std::variant — a Practical Experiment
![](https://1.bp.blogspot.com/-GZUf7pE_Mz8/X1U2JXvGsHI/AAAAAAAAEus/9tWxgy7RA8s4ah1z_uikvMELARFwxBUhACLcBGAsYHQ/s0/replacing_into_variant.png)
Some time ago I wrote about a new way to implement runtime polymorphism which is based not on virtual functions but on std::visit
and std::variant
. Please have a look at this new blog post where I experiment with this approach on my home project. The experiment is more practical than artificial examples.
See advantages, disadvantages and practical code issues.
5 Curious C++ Lambda Examples: Recursion, constexpr, Containers, and More
Please have a look at my quick blog post where I'll show you a few interesting lambda examples. Do you know how to write a recursive lambda? Store them in a container? Or invoke at compile time?
See how in this article.
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
How to Use The Newest C++ String Conversion Routines: std::from_chars
Intro
C++, before C++17, offered several options when it comes to string conversion:
sprintf
/snprintf
sscanf
atol
strtol
strstream
stringstream
to_string
stoi
and similar functions
And with C++17 you get another option: std::from_chars
! Wasn’t the old stuff good enough? Why do we need new methods?
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.