mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge pull request #7027 from leoetlino/cleanup
Use some C++17 features available since GCC 6
This commit is contained in:
@ -33,22 +33,10 @@
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
// ewww
|
||||
|
||||
#ifndef __has_feature
|
||||
#define __has_feature(x) (0)
|
||||
#endif
|
||||
|
||||
#if (__has_feature(is_trivially_copyable) && \
|
||||
(defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
|
||||
(defined(__GNUC__) && __GNUC__ >= 5) || defined(_MSC_VER)
|
||||
#define IsTriviallyCopyable(T) \
|
||||
std::is_trivially_copyable<typename std::remove_volatile<T>::type>::value
|
||||
#elif __GNUC__
|
||||
#define IsTriviallyCopyable(T) std::has_trivial_copy_constructor<T>::value
|
||||
#else
|
||||
#error No version of is_trivially_copyable
|
||||
#endif
|
||||
// XXX: Replace this with std::is_trivially_copyable<T> once we stop using volatile
|
||||
// on things that are put in savestates, as volatile types are not trivially copyable.
|
||||
template <typename T>
|
||||
constexpr bool IsTriviallyCopyable = std::is_trivially_copyable<std::remove_volatile_t<T>>::value;
|
||||
|
||||
// Wrapper class
|
||||
class PointerWrap
|
||||
@ -167,7 +155,7 @@ public:
|
||||
template <typename T>
|
||||
void DoArray(T* x, u32 count)
|
||||
{
|
||||
static_assert(IsTriviallyCopyable(T), "Only sane for trivially copyable types");
|
||||
static_assert(IsTriviallyCopyable<T>, "Only sane for trivially copyable types");
|
||||
DoVoid(x, count * sizeof(T));
|
||||
}
|
||||
|
||||
@ -197,7 +185,7 @@ public:
|
||||
template <typename T>
|
||||
void Do(T& x)
|
||||
{
|
||||
static_assert(IsTriviallyCopyable(T), "Only sane for trivially copyable types");
|
||||
static_assert(IsTriviallyCopyable<T>, "Only sane for trivially copyable types");
|
||||
// Note:
|
||||
// Usually we can just use x = **ptr, etc. However, this doesn't work
|
||||
// for unions containing BitFields (long story, stupid language rules)
|
||||
|
@ -56,15 +56,9 @@ public:
|
||||
{
|
||||
using std::ios_base;
|
||||
|
||||
// Since we're reading/writing directly to the storage of K instances,
|
||||
// K must be trivially copyable. TODO: Remove #if once GCC 5.0 is a
|
||||
// minimum requirement.
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
|
||||
static_assert(std::has_trivial_copy_constructor<K>::value,
|
||||
"K must be a trivially copyable type");
|
||||
#else
|
||||
// Since we're reading/writing directly to the storage of K instances,
|
||||
// K must be trivially copyable.
|
||||
static_assert(std::is_trivially_copyable<K>::value, "K must be a trivially copyable type");
|
||||
#endif
|
||||
|
||||
// close any currently opened file
|
||||
Close();
|
||||
|
Reference in New Issue
Block a user