creating a dispatcher of lambda functions
I’m thinking of creating a dispatcher()
function for a server by specifying pairs of {ID, LAMBDA} for server to choose from. All IDs are unique. Assuming I have send()
and receive()
functions supporting all allowed types, how would you write a dispatcher()
function that receives ID, selects corresponding lambda function, receives its parameters, invokes it and sends the result? I will have multiple instances of dispatcher()
for different instances of a server each with different sets of functions and I don’t want switch statements in implementation. Here is a simplified skeleton of such application (compiler explorer demo):
Why is the destructor being called multiple times if I got only one object?
In the code below I have one UserInterface shared_ptr obj, but when the program finished its destructor is called multiple times as in the output below:
strange results of aggregate initialization and decomposition
This is a two part question, one about aggregate initialization and the other about decomposition.
I have a function below doing aggregate element counting (if you want background, look here)
different compiler behavior with C++20 concepts and requires clause
I’ve written the following C++23 code and encountered an issue. In my code, I defined a concept to check if a sequence consists of float and double types. Using this concept, I defined a function (ChTest). However, the compiler behaves differently when using the requires clause versus not using it.
Detecting _BitInt type in _Generic
From ISO/IEC 9899:2024, 6.2.5 Types:
How to use call_once()?
From n3220, 7.28.2.1, The call_once
function
How to use call_once() in C23?
From n3220, 7.28.2.1, The call_once
function
What is the __STDC_VERSION__ value for C23?
What is the STDC_VERSION value for C11? asks about C11, and How can I use “nullptr” for null pointers prior to C23? says that the current versions of GCC and Clang define it to a placeholder value 202000L.
Why were min and max functions for fundamental types not added to C23?
Functions like fmaximum()/fminimum()
and other for FP are part of the C23 draft, but I found no mention of any min()
/max()
functions for other types.
What are source and execution character sets?
I was looking at the changes in C23, and found this in Annex M of the C23 draft: