March 2019

Expressing fire-and-forget coroutines more explicitly, -or- How to turn any coroutine into fire-...

The series continues.

Expressing fire-and-forget coroutines more explicitly, -or- How to turn any coroutine into fire-and-forget

by Raymond Chen

From the article:

Last time, we looked at how to mark a coroutine as fire-and-forget, meaning that the caller does not get any information about when the coroutine completes. This is fine as far as it goes, but it may not be what you want...

Trip Report: C++ Standards Meeting in Kona, February 2019--Botond Ballo

Everything you need to know.

Trip Report: C++ Standards Meeting in Kona, February 2019

by Botond Ballo

From the article:

A few weeks ago I attended a meeting of the ISO C++ Standards Committee (also known as WG21) in Kona, Hawaii. This was the first committee meeting in 2019; you can find my reports on 2018’s meetings here (November 2018, San Diego), here (June 2018, Rapperswil), and here (March 2018, Jacksonville). These reports, particularly the San Diego one, provide useful context for this post...

winrt::fire_and_forget was too forgetful

Heard about it?

winrt::fire_and_forget was too forgetful

by Raymond Chen

From the article:

C++/WinRT provides a handy helper class called winrt::fire_and_forget. It lets you specify that nobody is going to observe the result of the coroutine. This is handy because it lets you tell the compiler that the lack of observation is intentional, so it won’t generate a warning...

Quick Q: Compile-time loop optimisation

Quick A: each release of C++ allows more things to be done at compile time.

Recently on SO:

Compile-time loop optimisation

In C++14, constexpr function requirements were relaxed.

Previously, in C++11, constexpr functions could only contain typedefs, static_asserts and usings, but only a single return statement.

In C++14, it became possible to use loops in constexpr function bodies.

Because b was declared as constexpr char, it must be evaluated at compile time. The compiler then optimised out the isStringNice function, as it is not used at run time.

Game performance and compilation time improvements in Visual Studio 2019--Gratian Lup

Getting better!

Game performance and compilation time improvements in Visual Studio 2019

by Gratian Lup

From the article:

The C++ compiler in Visual Studio 2019 includes several new optimizations and improvements geared towards increasing the performance of games and making game developers more productive by reducing the compilation time of large projects. Although the focus of this blog post is on the game industry, these improvements apply to most C++ applications and C++ developers...

How do I design a class so that methods must be called in a certain order?--Raymond Chen

Simple but effective.

How do I design a class so that methods must be called in a certain order?

by Raymond Chen

From the article:

Suppose you have a class with some methods, and the methods must be called in a certain order. For example, suppose your class is for importing photos from a camera. First, you have to specify which camera you are importing from. Then you discover the pictures. Then you have to select which pictures you want to import, and set the options for how you want the download to occur. And finally, you download them...

C++ Insights - Implicit Conversions--Andreas Fertig

A good tool!

C++ Insights - Implicit Conversions

by Andreas Fertig

From the article:

This series is motivated by a brief conversation I had with Andreas. I asked him if he has some use case examples which show how C++ Insights can be helpful when teaching. I think there are many things. This article is the start of a series of five posts by Andreas which I will publish at Modernes C++ because I think C++ Insights is an invaluable tool to get a deeper insight in the C++ compiler magic. In case, you are new to C++ Insights consider this introductory article. Without further ado, Andreas post. When you follow the link near to each example, you can directly analyse the example in C++ Insight...

Quick Q: Deletion of copy-ctor & copy-assignment - public, private or protected?

Quick A: The meaning is the same for the compiler, so chooses what make sense to you.

Recently on SO:

Deletion of copy-ctor & copy-assignment - public, private or protected?

I would put them in the public section.

This is because deleting a constructor or an assignment operator is orthogonal to making them private / protected; and when these aren't deleted, they are public. Putting the deletions in one of those two sections seems to me like hinting "If I hadn't deleted them, I would have made them private/protected" - which is not a message you want to convey in your case.

Note, though, that the compiler doesn't care which section you put the deletion in.

Macro Evil in C++ Code

The C++ language opens extensive opportunities to go without macros. So let’s try to use macros as seldom as possible!

Macro Evil in C++ Code

by Andrey Karpov

From the article:

The ATL library provides such macros, as A2W, T2W and so on for string conversion. However, few people know that it is very dangerous to use these macros inside loops. Within the macro, a call to the alloca function occurs, which will repeatedly allocate memory on each loop iteration on the stack. A program makes show that it works correctly. Once a program starts to handle longer strings and the number of loop iterations increases, the stack can just end at the most unexpected moment.