Implement LWG2442, use references to call_once arguments instead of decay-copying them.
This change is being made in order to support non-copyable Callable objects, right? I'm not convinced that always adding const is the correct thing to do. Without the const the new signature won't accept rvalues as input but adding const requires Callable to be const-callable.
Why not provide two signatures? It's not perfect but I think it is better.
void call_once(once_flag&, _Callable&); // accepts non-const lvalues. void call_once(once_flag&, _Callable const&); // accepts rvalues and const lvalues.
That seems like it might indicate a problem. Do you know what is going on here? Are you sure you want to work around this?
Could you also add tests for the following:
I initially considered adding a perfectly forwarding non-variadic version when rvalue-refs are supported, and the two overloads you suggest above otherwise. This would add quite a lot of noise (each signature is present thrice). I guestimated const-ref to be enough, but I will add as many overloads and workarounds as you deem necessary.
If you expand the context a bit you will see that I took it from MoveOnly right above, I have not experienced the issue myself.
This is already the case, NonCopyable() is the function.
Good idea, will do.