Attributes are an underrated feature of the C++ language, in my opinion. I am saying this because I rarely see attributes used in code or samples featured in articles, videos, or talks. Although some of the standard attributes are targeted towards library implementers or address a limited number of scenarios (such as [[no_unique_address]], [[noreturn]], or [[carries_dependency]]), there are several that are quite useful in many situations. I refer here to [[nodiscard]], [[maybe_unused]], and [[deprecated]], which are the attributes I will talk about in this post.
The C++20 standard is complete and is supposed to be published later this year after the voting of the final draft takes place. However, there are books already with C++20 content. In this blog post I present a list of them. The C++ Standard Library, 3rd edition – Rainer Grimm Rainer is an author, consultant,…
When working in C++, you often hear about POD types (which stands for Plain Old Data). PODs are useful for communicating with code written in other programming languages (such as C or .NET languages). They can also be copied using memcpy (which is important because this is a fast, low-level function that provides performance benefits), and have other characteristics that are key for some scenarios. However, the new C++20 standard has deprecated the concept of POD types in favor of two more refined categories, which are trivial and standard-layout types. In this post, I will discuss what these categories are and when to use instead of POD.
One of the most important new features in the C++20 is coroutines. A coroutine is a function that has the ability to be suspended and resumed. A function becomes a coroutine if it uses any of the following:
- the co_await operator to suspend execution until resumed
- the co_return keyword to complete execution and optionally return a value
- the co_yield keyword to suspend execution and return a value
A coroutine must also have a return type that satisfies some requirements. However, the C++20 standard, only defines a framework for the execution of coroutines, but does not define any coroutine types satisfying such requirements. That means, we need to either write our own or rely on 3rd party libraries for this. In this post, I’ll show how to write some simple examples using the cppcoro library.
Some time ago, I wrote a short post about the C++20 ranges library with examples of how it can simplify our code. Let me take a brief example. Give a sequence of numbers, print the last two even numbers, but in reverse order.
The Microsoft Build 2020 event happened this week, and, unlike all previous editions, it was a digital event only. Moreover, it was also free, so everybody could attend the 48 hours marathon. Microsoft made a lot of announcements and released various products and services for Windows, Azure, Office, Visual Studio, Edge, and more. In this post, I will summarize the things that I found the most interesting for me.
In my previous post, I wrote about the support for C++20 modules in Visual Studio 2019 16.5. VC++ is not the only major compiler that has experimental support for modules. Clang has its own implementation, although only partial. In this post, I will discuss the support available in Clang 11. You can check the current status here.
Modules are one of the bigest changes in C++20 but the compilers’ support for them is a work in progress. The Visual C++ compiler has experimental support for modules that can be enabled by using the /experimental:module and /std:c++latest switches. In this post, I will walk through the core of the functionality available in Visual…
C++11 provides the atomic operations library that features classes and functions that enable us to perform atomic operations using lock-free mechanisms. There are primarily two class templates in this library, std::atomic and std::atomic_flag. The latter, which defines an atomic boolean type, is guaranteed to always be lock-free and is implemented using the lock-free atomic CPU instructions. The former however, may actually be implemented using mutexes or other locking operations. In this article, we will look at a new class template, introduced in C++20, std::atomic_ref.
This article has been updated for the version of WebView2 that requires Microsoft Edge WebView2 Runtime 88.0.705.50 or newer. In the previous article, we learned how to create a web view and display web content in a Windows desktop application. In this third article of the series, we will look in detail at navigation and…