C++17 In Detail

Hi there!

My name is Bartek, I'm a programmer from Cracow/Poland. This is my blog about C++ and native coding.

Quick jump links:

22 July 2019

Improve Multiplatform Code With __has_include and Feature Test Macros

Multiplatform code and __has_include, C++17

Two weeks ago, I showed you a sample that can detect if a function has a given overload. The example revolved around std::from_chars - low-level conversion routine for C++17. In the example, some “heavy” template patterns helped me to write the final code (most notably std::void_t and if constexpr). Maybe there are some other techniques we can use to check if a feature is available or not?

Today I’d like to have a look at __has_include and discuss the upcoming feature test macros that we’ll have in C++20.

15 July 2019

Five Awesome C++ Papers for Cologne ISO Meeting

Cologne 2019 ISO C++ 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. This is similar to article that I did for Kona and San Diego Meetings.

08 July 2019

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

Detect Function Overload, C++17

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

01 July 2019

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

Surprising conversions of const char* and bool, C++

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?

24 June 2019

C++17 In Detail, June Update: Foreword and Printing Tests

C++17 In Detail

Last Friday my book got a fresh update! It’s been three months since the previous release, and this time I brought foreword, new book format and some small content changes.

17 June 2019

Space Game: A std::variant-Based State Machine by Example

Space Game: A std::variant-based state machine by example

One of a powerful uses of std::variant is to implement State Machines. Some time ago I showed a simple example, but today we have something bigger. In today’s article by Nikolai Wuttke you’ll see how to leverage std::variant and build a space game!

27 May 2019

Heterogeneous Lookup in Ordered Containers, C++14 Feature

heterogeneous lookup in ordered containers, C++14

If you have a map of strings, like std::map<std::string, int> m; and you want to find some element by m.find("abc"). Do you have to pay the price and construct a std::string object? Can you optimize it?

Let’s have a look at one feature enabled in C++14 that might help optimize such container access.

20 May 2019

[Tip] How to Reference the C++ Standard or a Proposal

Reference the C++ Standard

You’re writing a document about C++, one feature or some cool programming technique. At one point you think that you have to prove that something works and that’s why you need to quote text from the Standard. How to do it?

18 May 2019

C++ Links #29 - recommended resources about coroutines

Welcome to new C++ Links - most important and useful articles, podcasts and videos that happen between 11th and 17th of May 2019.

In this week you will find links for two interesting resources: one about coroutines and the second about modern C++. You will also find a link describing what is the point of declaration, how to use constexpr for investigating errors and many more!

11 May 2019

C++ Links #28 - No more erase-remove idiom!

Welcome to new C++ Links - most important and useful articles, podcasts and videos that happen between 4th and 10th of May 2019.

Today you will find a link to a video that shows how Uniform Container Erasure will simplify erasing elements from containers, link to an introduction to modules, and tutorial how to change boost::filesystem to std::filesystem.

06 May 2019

Converting from Boost to std::filesystem

Converting 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? Today’s article is written by Scott Furry who writes about the differences he found when working with the two libs.

04 May 2019

C++ Links #27 - ADL, compiler optimisations, though C++ Quiz

Welcome to new C++ Links - most important and useful articles, podcasts and videos that happen between 27th of April 3rd of May 2019.

In this week you will find a little bit of C++ history - how namespaces were introduced in C++ and what design choices they have. You will also find a link to an extremely hard C++ quiz!

29 April 2019

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

Line Pos Debugging 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. In this post, I’ll describe one trick that is especially useful in Visual Studio but might also help in other IDE/compilers.

I’ll also show you how modern C++ and C++20 make code nicer.

22 April 2019

Overview of std::filesystem, my talk

C++17 String Operations

Last Tuesday, 16th April, I had a pleasure to talk about std::filesystem in our Cracow C++ User Group.

Here are the slides and additional comments.

© 2017, Bartlomiej Filipek, Blogger platform
Disclaimer: Any opinions expressed herein are in no way representative of those of my employers. All data and information provided on this site is for informational purposes only. I try to write complete and accurate articles, but the web-site will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.