How C++17 Benefits from the Boost Libraries

In today’s article, I’ll show you battle-tested features from the well-known Boost libraries that were adapted into C++17. With the growing number of elements in the Standard Library, supported by experience from Boost you can write even more fluent C++ code. Read on and learn about the cool things in C++.

READ MORE...

How to Convert Numbers into Text with std::to_char in C++17

In this post, I’ll show you how to use the newest, low-level, conversion routines form C++17. With the new functionality, you can quickly transform numbers into text and have super performance compared to previous techniques. Intro Until C++17, we had several ways of converting numbers into strings: sprintf / snprintf stringstream to_string itoa and 3rd-party libraries like boost - lexical cast And with C++17 we get another option: std::to_chars (along with the corresponding method from_chars) !

READ MORE...

C++17 In Detail - Print Version!

Last week was an important milestone for my book: it got a print version available at Amazon! In this post, I’ll share some details behind the event and the plans. The Print (on Demand) Since March 2019, I’ve been testing a few platforms that offer print on demand. One book came from Lulu.

READ MORE...

17 Smaller but Handy C++17 Features

When you see an article about new C++ features, most of the time you’ll see a description of major elements. Looking at C++17, there are a lot of posts (including articles from this blog) about structured bindings, filesystem, parallel algorithms, if constexpr, std::optional, std::variant… and other prominent C++17 additions.

READ MORE...

How To Detect Function Overloads in C++17, std::from_chars Example

The problem: a library function offers several overloads, but depending on the implementation/compiler, some of the overloads are not available. How to check the existence of an overload? And how to provide a safe fallback? In this article, I’ll show you a background “theory” and one case - std::from_chars that exposes full support for numbers or only integer support (in GCC, Clang).

READ MORE...

[Quick Case] Surprising Conversions of const char* to bool

If you have two function overloads foo(): one is taking const std::string& and the other taking bool. Which one of them will be selected when you call foo("hello world"); ? Let’s see where such a case might bite us and cause troubles? Intro Here’s the example once again void foo(const std::string& in) { std::cout << in << '\n'; } void foo(bool in) { std::cout << "bool: " << in << '\n';} foo("Hello World"); What’s the output?

READ MORE...

Converting from Boost to std::filesystem

As you may know std::filesystem evolved directly from Boost filesystem library. For a long time, it was available as a Technical Specification and later merged into C++17. Developers who used Boost can ask themselves what the differences between the two libs are. Can the code be easily converted to use std::filesystem?

READ MORE...