diff options
| author | shuffle2 <godisgovernment@gmail.com> | 2015-09-03 22:56:25 -0700 |
|---|---|---|
| committer | shuffle2 <godisgovernment@gmail.com> | 2015-09-03 22:56:25 -0700 |
| commit | a09b9bef8dff3423d9934e2bf7f34abd62dfc804 (patch) | |
| tree | d62e30ef6226fb7af3274db42b2107b7addf55fd /Source/Core | |
| parent | 8dd80b8e970c9da306892862bb09329d231aacc4 (diff) | |
| parent | 3f1b488a12f9dd8acdd8fa85331176fac0362afd (diff) | |
Merge pull request #2952 from lioncash/constexpr
CommonFuncs: Replace ArraySize define with constexpr equivalent
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Common/CommonFuncs.h | 12 | ||||
| -rw-r--r-- | Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/Source/Core/Common/CommonFuncs.h b/Source/Core/Common/CommonFuncs.h index 8e039b6066..1eb57842cd 100644 --- a/Source/Core/Common/CommonFuncs.h +++ b/Source/Core/Common/CommonFuncs.h @@ -17,16 +17,14 @@ #include <cstddef> #include <string> -#include <type_traits> #include "Common/CommonTypes.h" // Will fail to compile on a non-array: -// TODO: make this a function when constexpr is available -template <typename T> -struct ArraySizeImpl : public std::extent<T> -{ static_assert(std::is_array<T>::value, "is array"); }; - -#define ArraySize(x) ArraySizeImpl<decltype(x)>::value +template <typename T, size_t N> +constexpr size_t ArraySize(T (&arr)[N]) +{ + return N; +} #define b2(x) ( (x) | ( (x) >> 1) ) #define b4(x) ( b2(x) | ( b2(x) >> 2) ) diff --git a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp index 7fd80f3f2e..722b69f153 100644 --- a/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp +++ b/Source/Core/Core/HW/EXI_DeviceMemoryCard.cpp @@ -132,7 +132,7 @@ CEXIMemoryCard::CEXIMemoryCard(const int index, bool gciFolder) memory_card_size = memorycard->GetCardId() * SIZE_TO_Mb; u8 header[20] = {0}; - memorycard->Read(0, ArraySize(header), header); + memorycard->Read(0, static_cast<s32>(ArraySize(header)), header); SetCardFlashID(header, card_index); } |
