Async wait on file descriptor using Boost Asio

This is precisely the problem null_buffers was designed for. Sometimes a program must be integrated with a third-party library that wants to perform the I/O operations itself. To facilitate this, Boost.Asio includes a null_buffers type that can be used with both read and write operations. A null_buffers operation doesn’t return until the I/O object is … Read more

Using ‘boost::system::error_code’ in C++

Just visit: http://www.boost.org/doc/libs/1_55_0/libs/system/doc/reference.html#Header-error_code enum errc_t { success = 0, address_family_not_supported, //EAFNOSUPPORT address_in_use, //EADDRINUSE address_not_available, //EADDRNOTAVAIL already_connected, //EISCONN argument_list_too_long, //E2BIG argument_out_of_domain, //EDOM bad_address, //EFAULT bad_file_descriptor, //EBADF bad_message, //EBADMSG broken_pipe, //EPIPE connection_aborted, //ECONNABORTED connection_already_in_progress, //EALREADY connection_refused, //ECONNREFUSED connection_reset, //ECONNRESET cross_device_link, //EXDEV destination_address_required, //EDESTADDRREQ device_or_resource_busy, //EBUSY directory_not_empty, //ENOTEMPTY executable_format_error, //ENOEXEC file_exists, //EEXIST file_too_large, //EFBIG filename_too_long, //ENAMETOOLONG function_not_supported, //ENOSYS … Read more

how do you make a heterogeneous boost::map?

#include <map> #include <string> #include <iostream> #include <boost/any.hpp> int main() { try { std::map<std::string, boost::any> m; m[“a”] = 2; m[“b”] = static_cast<char const *>(“black sheep”); int i = boost::any_cast<int>(m[“a”]); std::cout << “I(” << i << “)\n”; int j = boost::any_cast<int>(m[“b”]); // throws exception std::cout << “J(” << j << “)\n”; } catch(…) { std::cout << … Read more

Detach a pointer from a shared_ptr? [duplicate]

What you’re looking for is a release function; shared_ptr doesn’t have a release function. Per the Boost manual: Q. Why doesn’t shared_ptr provide a release() function? A. shared_ptr cannot give away ownership unless it’s unique() because the other copy will still destroy the object. Consider: shared_ptr<int> a(new int); shared_ptr<int> b(a); // a.use_count() == b.use_count() == … Read more

Is boost shared_ptr thread safe?

boost::shared_ptr<> offers a certain level of thread safety. The reference count is manipulated in a thread safe manner (unless you configure boost to disable threading support). So you can copy a shared_ptr around and the ref_count is maintained correctly. What you cannot do safely in multiple threads is modify the actual shared_ptr object instance itself … Read more

How does boost bind work behind the scenes in general?

I like this piece of the bind source: template<class R, class F, class L> class bind_t { public: typedef bind_t this_type; bind_t(F f, L const & l): f_(f), l_(l) {} #define BOOST_BIND_RETURN return #include <boost/bind/bind_template.hpp> #undef BOOST_BIND_RETURN }; Tells you almost all you need to know, really. The bind_template header expands to a list of … Read more

Find Boost BGL vertex by a key

I think I have found such mechanism. It is called labeled_graph and is a part of BGL. Instead of using adjacency_list, one can use a predefined wrapper labeled_graph: typedef boost::labeled_graph< boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, Data >, std::string > Graph; After defining a graph like this, it is possible to access vertices in the following manner: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)