Why is this pointer needed when calling std::call_once()?
Because open_connection
is a non-static data member. It has to be called on something, and that something is the same instance, pointed at by this
(technically, non-static member functions have an implicit first parameter for this
.)
It could have been invoked with a different instance, although that wouldn't make sense in this case:
X x;
std::call_once(connection_init_flag, &X::open_connection, &x);