Copy a streambuf’s contents to a string

I don’t know whether it counts as “excessive copying“, but you can use a stringstream: std::ostringstream ss; ss << someStreamBuf; std::string s = ss.str(); Like, to read everything from stdin into a string, do std::ostringstream ss; ss << std::cin.rdbuf(); std::string s = ss.str(); Alternatively, you may also use a istreambuf_iterator. You will have to measure … Read more

Official “Boost library” Support for Android and iOS? [closed]

Got reply from boost community Yes. These platforms are not officially supported because no one has volunteered to run regression tests regularly for them. It is not possible for a Boost developer to test on all platforms. So developers depend on the test results of regression tests run by volunteers. For example, see http://beta.boost.org/development/tests/trunk/developer/summary.html If … Read more

Boost ASIO streambuf

The nomenclature for boost::asio::streambuf is similar to that of which is defined in the C++ standard, and used across various classes in the standard template library, wherein data is written to an output stream and data is read from an input stream. For example, one could use std::cout.put() to write to the output stream, and … Read more

boost::asio and Active Object

Boost.Asio can be used to encompass the intention of Active Object: decouple method execution from method invocation. Additional requirements will need to be handled at a higher-level, but it is not overly complex when using Boost.Asio in conjunction with other Boost libraries. Scheduler could use: boost::thread for thread abstraction. boost::thread_group to manage lifetime of threads. … Read more

Thread pool using boost asio

In short, you need to wrap the user’s provided task with another function that will: Invoke the user function or callable object. Lock the mutex and decrement the counter. I may not be understanding all the requirements for this thread pool. Thus, for clarity, here is an explicit list as to what I believe are … Read more

Boost async_* functions and shared_ptr’s

In short, boost::bind creates a copy of the boost::shared_ptr<Connection> that is returned from shared_from_this(), and boost::asio may create a copy of the handler. The copy of the handler will remain alive until one of the following occurs: The handler has been called by a thread from which the service’s run(), run_one(), poll() or poll_one() member … Read more

boost asio ssl async_shutdown always finishes with an error?

For a cryptographically secure shutdown, both parties musts execute shutdown operations on the boost::asio::ssl::stream by either invoking shutdown() or async_shutdown() and running the io_service. If the operation completes with an error_code that does not have an SSL category and was not cancelled before part of the shutdown could occur, then the connection was securely shutdown … Read more