[thread] call_once regression or it is planed so?
Hi,
With 1.54.0_beta1 following code fails to compile:
#include
On Tue, Jun 4, 2013 at 6:55 PM, Antony Polukhin
Hi,
With 1.54.0_beta1 following code fails to compile:
#include
void init_host(int); void init_host(); boost::once_flag instance_flag = BOOST_ONCE_INIT; int main() { boost::call_once(&init_host, instance_flag); }
In 1.53 it worked fine.
Is that meant to be so and no workaround is possible, or is it a bug?
I think, you should explicitly disambiguate the overload.
Antony Polukhin wrote:
Hi,
With 1.54.0_beta1 following code fails to compile:
#include
void init_host(int); void init_host(); boost::once_flag instance_flag = BOOST_ONCE_INIT; int main() { boost::call_once(&init_host, instance_flag); }
In 1.53 it worked fine.
Is that meant to be so and no workaround is possible, or is it a bug?
This is not guaranteed to work by the specification of std::call_once and boost::call_once. It has worked before because, I assume, it used boost::bind under the covers, and boost::bind does limited overload resolution based on the number of arguments. The usual workaround is int main() { void (*pf)() = init_host; boost::call_once( instance_flag, pf ); } or the equivalent formulation with a static_cast. If you have lambdas, []{ init_host(); } should work too.
participants (3)
-
Andrey Semashev
-
Antony Polukhin
-
Peter Dimov