Five Awesome C++ Papers for Cologne ISO Meeting

Today is the start day of Summer C++ISO meeting, this time in Cologne, Germany! This is the “feature-complete” meeting for C++20. It’s the last time we’ll see some new elements that are merged into the working draft. Let’s see what’s already in C++20 and let’s have a look at some smaller, but very handy proposals that might get into the standard.

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...

Improving Print Logging with Line Pos Info & Modern C++

No matter how proficient you are, I think, you might still use one of the primary methods of debugging: trace values using printf, TRACE, outputDebugString, etc… and then scan the output while debugging. Adding information about the line number and the file where the log message comes from is a very efficient method that might save you a lot of time.

READ MORE...

How to Iterate Through Directories in C++

How would you implement a function that searches for files with a given extension? For example, finding all text files? or *.cpp files? To code that solution you need a way to iterate through directories. Is that possible in C++ out of the box using the standard library? Let’s see some techniques and new elements that C++17 added.

READ MORE...

Dark Corner of C++ Corner Cases

The C ++ 17 standard consists of almost two thousands pages. Two thousand pages describing every single aspect of the language. Some pages relates to all kinds of details, exceptions, and things that you do not care about every day. We will try to look at a few such cases, which we hope never see in the production code.

READ MORE...

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

In the first part of the series we looked at lambdas from the perspective of C++03, C++11 and C++14. In that article, I described the motivation behind this powerful C++ feature, basic usage, syntax and improvements in each of the language standards. I also mentioned several corner cases. Now it’s time to move into C++17 and look a bit into the future (very near future!

READ MORE...

C++17 In Detail is 100% Ready!

I released “C++17 In Detail” in August 2018, and I set the status to 90%. I didn’t expect that writing of that remaining 10% would take me so long :) Now it’s high time to set the counter to 100%. That’s why I’m pleased to announce that my book “C++17 In Detail” is now done!

READ MORE...