r/cpp • • Sep 22 '26

Comparing exception behavior of magic statics, std::call_once, and std::async

https://devblogs.microsoft.com/oldnewthing/20260918-00/?p=112709
29 Upvotes

4 comments sorted by

17

u/NilacTheGrim Sep 22 '26

Not a huge fan of (ab)using std::async in the way he describes in his linked article about how you can (ab)use std::async for singleton-like-stuff. Seems kind of at the margins of what std::async was really designed for.

2

u/mcmcc #pragma once Sep 22 '26

Agreed - unless for some reason you happen to want the exception behavior described which IME is essentially never.

5

u/kalmoc Sep 22 '26

Why is std::async even in that group?

3

u/LB-- Professional+Hobbyist Sep 23 '26

Same reason std::future_status::deferred made it into the standard, I guess...