use union to remove warning (issue 105). (#108)

This commit is contained in:
Ivano Ras
2016-07-19 15:29:01 +01:00
committed by Thomas Krijnen
parent 240133515a
commit 42067de44c
+9 -3
View File
@@ -46,11 +46,17 @@
using namespace boost;
template <typename T>
union data_field {
char buffer[sizeof(T)];
T value;
};
template <typename T>
T sread(std::istream& s) {
char buf[sizeof(T)];
s.read(buf, sizeof(T));
return *((T*)buf);
data_field<T> data;
s.read(data.buffer, sizeof(T));
return data.value;
}
template <>