diff options
Diffstat (limited to 'src/common/common_funcs.h')
| -rw-r--r-- | src/common/common_funcs.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 4ace2cd33..17d1ee86b 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -108,6 +108,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void); | |||
| 108 | } \ | 108 | } \ |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | #define YUZU_NON_COPYABLE(cls) \ | ||
| 112 | cls(const cls&) = delete; \ | ||
| 113 | cls& operator=(const cls&) = delete | ||
| 114 | |||
| 115 | #define YUZU_NON_MOVEABLE(cls) \ | ||
| 116 | cls(cls&&) = delete; \ | ||
| 117 | cls& operator=(cls&&) = delete | ||
| 118 | |||
| 111 | #define R_SUCCEEDED(res) (res.IsSuccess()) | 119 | #define R_SUCCEEDED(res) (res.IsSuccess()) |
| 112 | 120 | ||
| 113 | /// Evaluates an expression that returns a result, and returns the result if it would fail. | 121 | /// Evaluates an expression that returns a result, and returns the result if it would fail. |
| @@ -128,4 +136,19 @@ namespace Common { | |||
| 128 | 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; |
| 129 | } | 137 | } |
| 130 | 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 | |||
| 131 | } // namespace Common | 154 | } // namespace Common |