Add beast::asio::basic_streambuf:

This is class whose interface is identical to the `boost::asio::basic_streambuf`, and uses an implementation that stores the data in multiple discontiguous linear buffers, expanding and shrinking as needed. The implementation is complex, with the core algorithm implemented in these functions `prepare`, `commit`, and `consume`. These functions need to be audited line by line for correctness. The Overlay peers are modified to use this new streambuf (its a drop in replacement for `boost::asio::basic_streambuf`). rippled runs connected to the network without assertions or crashes using this code.
Reviewers: @rec @JoelKatz @ximinez

aha, got it.  thanks!

On Wed, Oct 29, 2014 at 2:31 PM, HowardHinnant <notifications@github.com>
wrote:

> In src/beast/beast/asio/streambuf.h:
>
> > +auto
> > +basic_streambuf<Allocator>::mutable_buffers_type::
> > +    transform::operator() (element& e) const ->
> > +        value_type
> > +{
> > +    return value_type(e.data(),
> > +        (&e == &*std::prev(buffers_.end_)) ? buffers_.out_end_ : e.size()) +
> > +        ((&e == &*buffers_.begin_) ? buffers_.out_pos_ : 0);
> > +}
> > +
> > +//------------------------------------------------------------------------------
> > +
> > +template <class Allocator>
> > +basic_streambuf<Allocator>::~basic_streambuf()
> > +{
> > +    for(auto iter = list_.begin(); iter != list_.end();)
>
> Line 320-322 would invalidate iter if it weren't that line 318 is
> incrementing iter off of e prior to the destruction and deallocation.
> Iterator increment must happen before the loop body, instead of after as
> would happen if the increment happened in the for statement.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ripple/rippled/pull/662/files#r19561281>.
>