17#ifndef IO_BUF_HPP_INCLUDED
18#define IO_BUF_HPP_INCLUDED
24#include "buffer/shared_buffer.hpp"
25#include "utility/byte_array.hpp"
31constexpr int Answer = 42;
34 chops::const_shared_buffer m_buf;
37 io_buf_and_int (
const chops::const_shared_buffer& buf) : m_buf(buf), m_num(Answer) { }
39 std::size_t size()
const noexcept {
return m_buf.size(); }
44 auto ba = chops::make_byte_array(0x20, 0x21, 0x22, 0x23, 0x24);
45 return chops::const_shared_buffer(ba.data(), ba.size());
49 auto ba = chops::make_byte_array(0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46);
50 return chops::const_shared_buffer(ba.data(), ba.size());
53auto make_io_buf_vec() {
54 return std::vector<chops::const_shared_buffer> { make_io_buf1(), make_io_buf2() };
57auto make_io_buf_and_int_vec() {
58 return std::vector<io_buf_and_int> { io_buf_and_int(make_io_buf1()), io_buf_and_int(make_io_buf2()) };
62std::size_t accum_io_buf_size (
const std::vector<E>& data_vec) {
63 return std::accumulate (data_vec.cbegin(), data_vec.cend(),
static_cast<std::size_t
>(0u),
64 [] (std::size_t sum,
const E& elem) { return sum += elem.size(); } );