DiscIO: Use std::optional in Volume and Blob

This commit is contained in:
JosJuice
2017-06-04 10:33:14 +02:00
parent e23cfc2965
commit c3fa0d6edf
23 changed files with 232 additions and 237 deletions

View File

@ -16,6 +16,7 @@
#include <array>
#include <memory>
#include <optional>
#include <string>
#include "Common/CommonTypes.h"
@ -46,13 +47,12 @@ public:
// NOT thread-safe - can't call this from multiple threads.
virtual bool Read(u64 offset, u64 size, u8* out_ptr) = 0;
template <typename T>
bool ReadSwapped(u64 offset, T* buffer)
std::optional<T> ReadSwapped(u64 offset)
{
T temp;
if (!Read(offset, sizeof(T), reinterpret_cast<u8*>(&temp)))
return false;
*buffer = Common::FromBigEndian(temp);
return true;
return {};
return Common::FromBigEndian(temp);
}
protected: