
Hi Peter, --- Peter Dimov <pdimov@mmltd.net> wrote:
Why is
http://asio.sourceforge.net/boost-asio-proposal-0.3.6/libs/asio/doc/tutorial...
using raw pointers, strdup, new, free and delete? This is soo 1996. Tutorials shoud teach.
Yep, this already came up in a review and I'm planning to change it. IIRC, the motivation for doing it this way was: - to avoid introducing too many boost facilities at once - to illustrate the "exactly-once" callback invocation Since I want to keep the tutorial as simple as possible, I'm a bit undecided about what to put instead though. I want to ensure that whatever I use instead doesn't distract from the things that I am trying to teach. For example, one option I'm considering is to simply replace them with shared_ptr<socket>, shared_ptr<std::string> etc, but keep using free functions as callbacks. The "distraction" I see with std::string is that I probably need to explain how calling asio::buffer() on it uses the data() member function, and the conditions under which the pointer returned by data() is invalidated. Any other ideas would be appreciated. Explaining features in isolation is not easy. Cheers, Chris