When it comes to format a piece of text in C++ there are several ways you can employ: I/O streams, particularly std::stringstream with stream operations (such as operator <<) printf family of functions, particularly sprintf the C++20 format library, particularly std::format / std::format_to any 3rd party library, {fmt} in particular (the source of the new…
Category: C++
How to convert an enum to string in C++
Enumerations are widely used and we often need to convert enum values to strings (typically for recording values in logs) but there is no option at the language level or a utility in the standard library to make it possible. Therefore, developers are usually handcrafting their own solutions. Let’s say we have the following enum:…
The curious case of error C2065: ‘IID_InterfaceName’: undeclared identifier
Recently, I stumbled across a peculiar error that I found nothing about on the web. Although I got rid of it, I didn’t figure out what the problem was. This post is merely the story of what happened. I am working on a project that contains both C++ and C# projects. The C++ ones used…
Notes on std::optional’s monadic operations
The C++23 standard includes several new functions to the std::optional class: and_then, transform, or_else. These are monadic operations and are intended to simplify the chaining of several operations that may or may not produce a value. In this post, I want to briefly present these functions and to make some observations on them. A starting…
Using Microsoft Edge in a native Windows desktop app – part 6
The WebView2 control supports different printing scenarios. In this new article, I’ll show you how to display a print dialog and, respectively, how to print to PDF.
Using Microsoft Edge in a native Windows desktop app – part 5
This article is a new installment in the series about using the Webview2 control in a native application. In this post, I will show how to execute a JavaScript script. Articles in this series: Part 1: Introduction to Edge and WebView2 Part 2: Creating a WebView2 component Part 3: Navigation and other events Part 4:…
How to make chunks of a range in C++23
Last year, I wrote a blog post about new C++23 range adaptors for joining and zipping. The C++23 standard includes a longer lists of range adapters (you can find a list here). Among them, there are several adaptors used for creating views consisting of chunks or “windows” of the elements of a given range. In…
The C++23 standard break-down
A break-down of the most important features of C++23 with description and links to learning resources.
A study of several issues found with static analysis
The static analysis of our code base has identified lately several several issues in the C++ code that I had to fix. Once again, this help me I realize how it is to make mistakes that are usually hard to find by just looking at the code (with a human eye). I believe it is…
Three new utility functions in C++23
Some time ago I wrote a blog post called Three C++23 features for common use. In this article, I want to continue on that idea and discuss three new utility functions that were added to C++23.