-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.h
33 lines (29 loc) · 1017 Bytes
/
common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include <boost/fusion/adapted.hpp>
#include <boost/iostreams/device/mapped_file.hpp>
#include <fstream>
#include <iterator>
namespace data {
struct float3 {
float x, y, z;
};
using float3_vector = std::vector<float3>;
using float_vector = std::vector<float>;
}
BOOST_FUSION_ADAPT_STRUCT(data::float3, x, y, z)
namespace source {
struct mapped_file {
boost::iostreams::mapped_file mmap{ "input.txt", boost::iostreams::mapped_file::readonly };
using iterator = char const*;
boost::iterator_range<iterator> get_data() const {
return { mmap.const_data(), mmap.const_data() + mmap.size() };
}
};
struct iostreams {
std::ifstream ifs{"input.txt"};
std::istreambuf_iterator<char> f_{ifs >> std::noskipws}, l_;
std::vector<char> v{f_, l_};
using iterator = std::vector<char>::const_iterator;
boost::iterator_range<iterator> get_data() const { return { v.begin(), v.end() }; }
};
}