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…
In the second part of this series, we will see how to use the WebView2 control in a C++ Windows desktop application. We will use a single document interface MFC application that features a toolbar where you can specify an address to navigate to and buttons to navigate back and forward as well as reloading the current page or stopping navigation.
Earlier this month, Microsoft has released the new version of its Edge browser, based on the Chromium project. The new browser works on Windows 10, Windows 8.x, and Windows 7, as well as macOS, iOS, and Android. If your application display web content, you can use the new Edge browser as the rendering engine. This is made possible through the Microsoft Edge WebView2 control, currently in developer preview. In this series, I will show how you can do this in a C++ Windows desktop application.