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 <boost/asio/placeholders.hpp>:

  boost::arg<1>& error
    = boost::asio::placeholders::detail::placeholder<1>::get();

Using that function instead could be an alternative, but since it is not in the "public" namespace and is not in the library documentation, using it would not be a good idea for maintainability.

Finally, is there any documentation stating the fact that placeholders such as boost::asio::placeholders::error and _1 are static? I can't find any in the Asio or Bind documentation, and I feel this is a limitation that should at least be documented.

Thank you,
--
Olivier Sauvageau