diff options
| author | 2021-04-01 23:04:54 -0700 | |
|---|---|---|
| committer | 2021-05-05 16:40:49 -0700 | |
| commit | 02c2b28cd0f341fd955f9648d9174777e0b60689 (patch) | |
| tree | 1e9ce7f349b8cf14d0537ecb952da0435227515c | |
| parent | hle: kernel: Add initial impl. of KLinkedList. (diff) | |
| download | yuzu-02c2b28cd0f341fd955f9648d9174777e0b60689.tar.gz yuzu-02c2b28cd0f341fd955f9648d9174777e0b60689.tar.xz yuzu-02c2b28cd0f341fd955f9648d9174777e0b60689.zip | |
common: common_funcs: Add Size helper function.
| -rw-r--r-- | src/common/common_funcs.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 73c8c9354..19bb021e0 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -136,4 +136,19 @@ namespace Common { | |||
| 136 | return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; | 136 | return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | // std::size() does not support zero-size C arrays. We're fixing that. | ||
| 140 | template <class C> | ||
| 141 | constexpr auto Size(const C& c) -> decltype(c.size()) { | ||
| 142 | return std::size(c); | ||
| 143 | } | ||
| 144 | |||
| 145 | template <class C> | ||
| 146 | constexpr std::size_t Size(const C& c) { | ||
| 147 | if constexpr (sizeof(C) == 0) { | ||
| 148 | return 0; | ||
| 149 | } else { | ||
| 150 | return std::size(c); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 139 | } // namespace Common | 154 | } // namespace Common |