Articles & Books

How To Detect Function Overloads in C++17/20, std::from_chars Example--Bartlomiej Filipek

Which way you prefer?

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

by Bartlomiej Filipek

From the article:

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

Template Specialization--Rainer Grimm

The series continue.

Template Specialization

by Rainer Grimm

From the article:

Templates define the behavior of families of classes or functions. Often it is required that special types or non-types may be treated special. To support this use case, you can specialize templates.

C++20 three-way comparison operator: Part 2--Gajendra Gulgulia

Simplifying your life.

C++20 three-way comparison operator: Part 2

by Gajendra Gulgulia

From the article:

In the first part of the tutorial series, I laid out the motivation behind C++20’s three way comparison operator: <=> and showcased the simplest use case how it can be useful to remove the boilerplate code for comparison operators : ==, >=, <=, !=, >, < if the semantics of the program requires us to implement them and how they can be gotten rid of by using the defaulted version of three way comparison operator...

Template Argument Deduction of Class Templates--Rainer Grimm

The series continue.

Template Argument Deduction of Class Templates

by Rainer Grimm

From the article:

In my last post Template Arguments, I wrote about function template type deduction (C++98) and auto type deduction (C++11). Today I wear more modern hats. I start with automatic type deduction of non-type template parameters and class templates (C++17) and finish with automatic type deduction of concepts (C++20).

Reversing words of a string with ranges--Marco Arena

A new interpretation of a classical problem:

Reversing words of a string with ranges

by Marco Arena

From the article:

In this post I share the story of a “C++ aha-moment”, hence I use the hashtag #thatsarotate (resumed last Saturday at the Italian C++ Conference 2021 to honor our keynote speaker Sean Parent). Why not sharing your own stories of “C++ aha-moments” adding the same hashtag to your tweets, posts, or whatever? It would be really appreciated...

7 Top Tips for Debugging C++ -- Greg Law

In this guest blog post, Greg will share a few top tips for debugging C++ code.

7 Top Tips for Debugging C++

by Greg Law

From the article:

Debugging is central to programming – you cannot be a great programmer without being great at debugging. Hopefully, my favorite C++ debugging tips will help you be as clever and productive debugging your code as you are writing it in the first place.

  • #1 Have a full kit of debugging tools
  • #2 Conditional breakpoints
  • #3 Watchpoints
  • #4 User-defined debugging commands in Python
  • #5 Pretty-print structures
  • #6 Time Travel Debugging
  • #7 Command find to search for a byte sequence

Transrangers: An Efficient, Composable Design Pattern for Range Processing -- Joaquín M López Muñoz

Another twist on ranges.

Transrangers: An Efficient, Composable Design Pattern for Range Processing

by Joaquín M López Muñoz

From the article:

Transrangers are a new design pattern for efficient, composable range processing that can be faster than pull-based C++/Range-v3 views whithout losing any expressiveness. The underlying architecture combines ideas from push processing with the internalization of control flow. Transrangers can be used on their own or be leveraged as an implementation detail of range libraries to improve the performance of view-based operations.

 

Painless C++ Coroutines--Gajendra Gulgulia

Another introduction.

Painless C++ Coroutines-Part 1

Painless C++ Coroutines-Part 2

Painless C++ Coroutines-Part 3

Painless C++ Coroutines-Part 4

Painless C++ Coroutines-Part 5

by Gajendra Gulgulia

From the article:

Incidentally I found the mechanics of coroutines quite obfuscating given the number of implicit and under-the-hood calls to several methods associated with coroutine and their return type objects. Even with tons of articles and posts on the web, I started to have a feeling that coroutines is an arcane feature that can be understood by the very few who are either in committee or are renowned authors of blogs, books and articles or experienced C++ library authors.
But after a month of arduous efforts and experiments, trials and errors to understand coroutine, I decided to write a tutorial series that can be used by any intermediate C++ developer to understand coroutine and in the effort I made sure that this article is the last that anyone should refer to, to learn, understand and demystify coroutines without being a super experienced C++ library author. If you’re impatient to get started, then directly jump to section 1: What are coroutines? Else read the Introduction section to get detailed highlight of the tutorial series...