[asio][bind] Access violation with placeholders used by static objects
Hello,
I had an access violation issue using boost::asio::placeholders::error as
parameter to boost::bind in a class that was used as type for a static
class member object. I realized that the placeholders, both those in Asio
and those in Bind (e.g., _1) are themselves static objects, and thus found
out that my problem was due to the famous undefined order of initialization
of static objects.
I was able to fix my problem simply by encapsulating my static object in a
function and making sure it's called only after main() has started.
However, I'm still wondering, has this issue ever been discussed and any
correction or alternative proposed? I couldn't find anything on the topic.
On the other hand, I noticed that Asio's placeholders are initialized from
functions, e.g. from
participants (1)
-
Olivier Sauvageau