summaryrefslogtreecommitdiffstats
path: root/src/common/file_util.h
diff options
context:
space:
mode:
authorTony Wasserka <neobrainx@gmail.com>2015-07-13 21:39:58 +0200
committerTony Wasserka <neobrainx@gmail.com>2015-07-13 21:39:58 +0200
commit884b681ccaf3cb4057ca0ed0102e446736bb535f (patch)
tree9359e9b88f0147879c672638d8c02960d2179d3a /src/common/file_util.h
parentMerge pull request #859 from Apology11/master (diff)
parentCiTrace: Clean up initialization method. (diff)
downloadyuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.gz
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.bz2
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.lz
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.xz
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.zst
yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.zip
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 8fe772aee..9637d1b85 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -181,6 +181,10 @@ public:
template <typename T>
size_t WriteArray(const T* data, size_t length)
{
+ static_assert(std::is_standard_layout<T>::value, "Given array does not consist of standard layout objects");
+ // TODO: gcc 4.8 does not support is_trivially_copyable, but we really should check for it here.
+ //static_assert(std::is_trivially_copyable<T>::value, "Given array does not consist of trivially copyable objects");
+
if (!IsOpen()) {
m_good = false;
return -1;
@@ -203,6 +207,12 @@ public:
return WriteArray(reinterpret_cast<const char*>(data), length);
}
+ template<typename T>
+ size_t WriteObject(const T& object) {
+ static_assert(!std::is_pointer<T>::value, "Given object is a pointer");
+ return WriteArray(&object, 1);
+ }
+
bool IsOpen() { return nullptr != m_file; }
// m_good is set to false when a read, write or other function fails