how to do performance test using the boost library for a custom library

Okay, so I added serialization to the types (why did you leave it out?) struct X { int p; double q; private: friend boost::serialization::access; template <typename Ar> void serialize(Ar& ar, unsigned) { ar & BOOST_SERIALIZATION_NVP(p); ar & BOOST_SERIALIZATION_NVP(q); } }; struct Y { float m; double n; private: friend boost::serialization::access; template <typename Ar> void serialize(Ar& … Read more

asio How to change the executor inside an awaitable?

You want to associate your executor with the completion token, and then let post/dispatch/defer figure it out from there: co_await asio::post(bind_executor(pstrand, asio::use_awaitable)); See also e.g. When must you pass io_context to boost::asio::spawn? (C++) or boost::asio::bind_executor does not execute in strand for more details on how it works/why it works/when it works. It does in fact … Read more

Get private data members for non intrusive boost serialization C++

You can use good old-fashioned friends: Live On Coliru template <typename T> class A { public: A(const T &id) : m_id(id) {} private: template <typename Ar, typename U> friend void boost::serialization::serialize(Ar&,A<U>&,const unsigned); T m_id; }; namespace boost { namespace serialization { template <class Archive, typename T> void serialize(Archive &ar, A<T> &a, const unsigned int) { … Read more

How do I take ownership of an abandoned boost::interprocess::interprocess_mutex?

Unfortunately, this isn’t supported by the boost::interprocess API as-is. There are a few ways you could implement it however: If you are on a POSIX platform with support for pthread_mutexattr_setrobust_np, edit boost/interprocess/sync/posix/thread_helpers.hpp and boost/interprocess/sync/posix/interprocess_mutex.hpp to use robust mutexes, and to handle somehow the EOWNERDEAD return from pthread_mutex_lock. If you are on some other platform, you … Read more

Boost.Python: Wrap functions to release the GIL

Exposing functors as methods is not officially supported. The supported approach would be to expose a non-member function that delegates to the member-function. However, this can result in a large amount of boilerplate code. As best as I can tell, Boost.Python’s implementation does not explicitly preclude functors, as it allows for instances of python::object to … Read more

Boost.Asio as header-only

AFAIK you can get the non-boost version of asio from http://think-async.com/Asio/AsioAndBoostAsio “— Boost.Asio uses the Boost.System library to provide support for error codes ( boost::system::error_code and boost::system::system_error). Asio includes these under its own namespace ( asio::error_code and asio::system_error). The Boost.System version of these classes currently supports better extensibility for user-defined error codes. — Asio is … Read more

What are the differences between std::variant and boost::variant?

Assignment/emplacement behavior: boost::variant may allocate memory when performing assignment into a live variant. There are a number of rules that govern when this can happen, so whether a boost::variant will allocate memory depends on the Ts it is instantiated with. std::variant will never dynamically allocate memory. However, as a concession to the complex rules of … Read more

Exception running boost asio ssl example

OK, for anyone finding this in the future, you need to create your certificates and sign them appropriately. Here are the commands for linux: //Generate a private key openssl genrsa -des3 -out server.key 1024 //Generate Certificate signing request openssl req -new -key server.key -out server.csr //Sign certificate with private key openssl x509 -req -days 3650 … Read more

adding custom vertices to a boost graph

I don’t understand what you want to do exactly. Do you want to associate some data to vertices? Then use bundled properties. //Define a class that has the data you want to associate to every vertex and edge struct Vertex{ int foo;} struct Edge{std::string blah;} //Define the graph using those classes typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, … Read more