Quick Q: How can I call a function only one? -- StackOverflow
Quick A: std::call_once.
Recently on StackOverflow:
Standard library function for running a function only once
Is there some standard library function/class the behaviour of this lambda expression:
void some_func(int some_arg, float some_other_arg){ static int do_once = ([](){ // will be run once upon first function call but never again return 0; // dummy return value })(); // will always run }t feels like such a hack to write this, but I can't think of another way of doing this other than simply calling the function in
main, but what I'm actually doing depends upon template parameters and I need to keep it as generic as possible.For context: I register a function with
atexitfor every different template parameter, but only once: the first time it is called.

On Sticky Bits:
We don't normally link to pleas to
Bulldozer00's appreciation for Alex Stepanov's introduction for Bjarne Stroustrup at CppCon. We already linked to the video last week -- but if you didn't watch it then, do yourself a favor and spend 6 minutes now getting your workweek off to a great start.