Articles & Books

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

How to check if a function can be invoked? SFINAE? if constexpr?<img alt="" data-cke-saved-src="https://3.bp.blogspot.com/-LPhyXKA1CT8/XSQ-b9BNhgI/AAAAAAAAD2w/ooIxhAR8Q3wmu7xqq2-CTsU8bVLnGWvvACLcBGAs/s1600/funcoverload.png" src="https://3.bp.blogspot.com/-LPhyXKA1CT8/XSQ-b9BNhgI/AAAAAAAAD2w/ooIxhAR8Q3wmu7xqq2-CTsU8bVLnGWvvACLcBGAs/s1600/funcoverload.png" 300px;="" height:="" 96px;="" float:="" right;"="" style="height: 74px; width: 230px; float: right;">

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

by Bartlomiej Filipek

From the article:

Working with real examples is better in most of the cases, so I like that we could show how the detection pattern works on a real function: std::from_chars. The full check used various of techniques: SFINAE, void_t, decltype, std::declval, std::true_type, std::false_type and partial template specialisation. Plus we even used if constexpr!

What Every C++ Developer Should Know to (Correctly) Define Global Constants--Jonathan Boccara

C++17 to the rescue.

What Every C++ Developer Should Know to (Correctly) Define Global Constants

by Jonathan Boccara

From the article:

Constant values are an everyday tool to make code more expressive, by putting names over values.

For example, instead of writing 10 you can write MaxNbDisplayedLines to clarify your intentions in code, with MaxNbDisplayedLines being a constant defined as being equal to 10.

Even though defining constants is such a basic tool to write clear code, their definition in C++ can be tricky and lead to surprising (and even, undefined) behaviour, in particular when making a constant accessible to several files.

Everything in this article also applies to global variables as well as global constants, but global variables are a bad practice contrary to global constants, and we should avoid using them in the first place...

std::format in C++20--Victor Zverovich

Just great!

std::format in C++20

by Victor Zverovich

From the article:

I’m happy to announce that the Text Formatting proposal (std::format) made it into the C++20 Committee Draft at the Cologne meeting, just in time before the feature freeze. This concludes a three-year long design, implementation, and standardization effort.

Here’s a brief history of the proposal aka “what took you so long?”...

Trip report: Summer ISO C++ standards meeting (Cologne)--Herb Sutter

Many things happened!

Trip report: Summer ISO C++ standards meeting (Cologne)

by Herb Sutter

From the article:

Obligatory comment: The C++20 Eagle has wings.

At noon today, July 20 2019, the ISO C++ committee completed its summer meeting in Cologne, Germany, hosted with thanks by Think-Cell, SIGS Datacom, SimuNova, Silexica, Meeting C++, Josuttis Eckstein, Xara, Volker Dörr, Mike Spertus, and the Standard C++ Foundation...

Expressiveness, Nullable Types, and Composition (Part 1)

How do you do it?

Expressiveness, Nullable Types, and Composition (Part 1)

by Rafael Varago

From the article:

We’re software developers, our mission is to provide software that solves problems. And in its essence, writing software is all about composition.

We have a big problem to solve, so we break it up into smaller pieces that can be more easily comprehended, and then we compose these smaller pieces together into working software...

The Regular Expression Library--Rainer Grimm

A quick introduction.

The Regular Expression Library

by Rainer Grimm

From the article:

My original plan was it to write about the rules of the C++ Core Guidelines to the regex and chrono library, but besides the subsection title, there is no content available. I already wrote a few posts about time functionality. So I'm done. Today, I fill the gap and write about the regex library.