Relative Content

Tag Archive for c++c++23

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):

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.

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.