Skip to content

Instantly share code, notes, and snippets.

@snaewe
Created June 11, 2012 20:23
Show Gist options
  • Save snaewe/2912429 to your computer and use it in GitHub Desktop.
Save snaewe/2912429 to your computer and use it in GitHub Desktop.
#include <boost/interprocess/streams/vectorstream.hpp>
#include <vector>
#include <string>
typedef std::vector<char> CharVec;
typedef boost::interprocess::basic_vectorstream<CharVec> vectorstream;
typedef boost::interprocess::basic_ivectorstream<CharVec> ivectorstream;
typedef boost::interprocess::basic_ovectorstream<CharVec> ovectorstream;
int main()
{
std::string hello("Hello World");
vectorstream vstr;
vstr << hello;
std::string str;
while (vstr && (vstr >> str))
{
std::cout << str << " ";
}
std::cout << std::endl;
CharVec const& vc = vstr.vector();
std::cout
<< "size: " << vc.size()
<< std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment