mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge pull request #6190 from JosJuice/is-trivially-copyable-vs
Remove IsTriviallyCopyable hack for VS
This commit is contained in:
@ -124,15 +124,18 @@ public:
|
||||
// so that we can use this within unions
|
||||
constexpr BitField() = default;
|
||||
|
||||
// Visual Studio (as of VS2017) considers BitField to not be trivially
|
||||
// copyable if we delete this copy assignment operator.
|
||||
// https://developercommunity.visualstudio.com/content/problem/101208/c-compiler-is-overly-strict-regarding-whether-a-cl.html
|
||||
#ifndef _MSC_VER
|
||||
// We explicitly delete the copy assignment operator here, because the
|
||||
// default copy assignment would copy the full storage value, rather than
|
||||
// just the bits relevant to this particular bit field.
|
||||
// Ideally, we would just implement the copy assignment to copy only the
|
||||
// relevant bits, but this requires compiler support for unrestricted
|
||||
// unions.
|
||||
// TODO: Implement this operator properly once all target compilers
|
||||
// support unrestricted unions.
|
||||
// relevant bits, but we're prevented from doing that because the savestate
|
||||
// code expects that this class is trivially copyable.
|
||||
BitField& operator=(const BitField&) = delete;
|
||||
#endif
|
||||
|
||||
__forceinline BitField& operator=(T val)
|
||||
{
|
||||
|
@ -41,14 +41,11 @@
|
||||
|
||||
#if (__has_feature(is_trivially_copyable) && \
|
||||
(defined(_LIBCPP_VERSION) || defined(__GLIBCXX__))) || \
|
||||
(defined(__GNUC__) && __GNUC__ >= 5)
|
||||
(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
|
||||
#elif _MSC_VER
|
||||
// (shuffle2) see https://github.com/dolphin-emu/dolphin/pull/2218
|
||||
#define IsTriviallyCopyable(T) 1
|
||||
#else
|
||||
#error No version of is_trivially_copyable
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user