Skip to content

Instantly share code, notes, and snippets.

@ivanstepanovftw
Last active February 10, 2019 18:41
Show Gist options
  • Save ivanstepanovftw/0a628030087ddec95d79fd372030bbd0 to your computer and use it in GitHub Desktop.
Save ivanstepanovftw/0a628030087ddec95d79fd372030bbd0 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <boost/iostreams/device/mapped_file.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
int main(int argc, char* argv[]) {
using namespace std;
using namespace boost::interprocess;
using namespace std::string_literals;
std::string path = "Boost";
//00000000: 0300 0000 0000 0000 4654 5733 3333 3333 ........FTW33333
//00000010: 3333 33
std::string data1 = "FTW";
auto read = [](void *out, size_t size) -> size_t {
memset(out, 0x33, size);
return size;
};
std::ofstream os(path, std::ios_base::binary|std::ios_base::out);
boost::archive::binary_oarchive arch(os, boost::archive::no_header);
arch<<data1;
std::vector<char> data2;
data2.reserve(7);
read(&data2[0], 7);
os.write(&data2[0], 7);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment