boost::streambuf簡易テスト
1221 ワード
#include "stdafx.h"
#define BOOST_ENABLE_ASSERT_HANDLER
#include
#include
#include
int _tmain(int argc, _TCHAR* argv[])
{
boost::asio::streambuf sb;
char buffer[] = "Hello,World!";
size_t len = strlen(buffer);
sb.prepare(sizeof(len));
sb.sputn((const char*)&len, sizeof(len));
sb.prepare(len);
sb.sputn(buffer, len);
len = boost::asio::buffer_size(sb.data());
size_t getLen = 0;
getLen = sb.size();
sb.commit(sizeof(len));
//sb.sgetn((char*)&getLen, sizeof(getLen));
int* p = (int*)boost::asio::buffer_cast(sb.data());
sb.consume(sizeof(getLen));
p = (int*)boost::asio::buffer_cast(sb.data());
getLen = sb.size();
len = boost::asio::buffer_size(sb.data());
BOOST_ASSERT(0);
return 0;
}
void boost::assertion_failed(char const * expr,
char const * function, char const * file, long line) // user defined
{
stringstream ss;
ss<< expr << ", " << function << ", " << file << ", " << line << '
' << ends;
OutputDebugStringA(ss.str().c_str());
}