ChunkFile has allowed me to accidentally "Do" a non-POD for the last time!

This commit is contained in:
Jordan Woyak
2013-04-09 18:57:39 -05:00
parent 5c374b2718
commit 385d8e2b15
18 changed files with 43 additions and 30 deletions

View File

@ -32,6 +32,7 @@
#include <list>
#include <deque>
#include <string>
#include <type_traits>
#include "Common.h"
#include "FileUtil.h"
@ -139,11 +140,17 @@ public:
template <typename T>
void Do(T& x)
{
// TODO: Bad, Do(some_non_POD) will compile and fail at runtime
// type_traits are not fully supported everywhere yet
// Ideally this would be std::is_trivially_copyable, but not enough support yet
static_assert(std::is_pod<T>::value, "Only sane for POD types");
DoVoid((void*)&x, sizeof(x));
}
template <typename T>
void DoPOD(T& x)
{
DoVoid((void*)&x, sizeof(x));
}
template <typename T>
void DoPointer(T*& x, T* const base)