Boost之vector<boost::asio::mutable_buffer>转char*

#include <iostream>
#include <vector>
#include <list>
#include <iterator>
#include <boost/array.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/asio/buffers_iterator.hpp>
#include <boost/asio/buffer.hpp>
using namespace std;

int main(){
	char read_buf[] = "12304567890";
	//vector<boost::asio::mutable_buffer> ---> char*
	std::vector<boost::asio::mutable_buffer> buffers;
  buffers.push_back(boost::asio::buffer(read_buf));

	boost::asio::buffers_iterator<vector<boost::asio::mutable_buffer>, char> it;
	//one way
	it = buffers_begin(buffers);
	
	//second way
	//it = boost::asio::buffers_iterator<vector<boost::asio::mutable_buffer>, char>::begin(buffers);

	for(int i = 0 ;i < strlen(read_buf) ;i ++)
		cout << "bi5 = " << it[i] << endl;
}

上一篇:Node.js Buffers 完整指南


下一篇:关于内存使用率监控