diff options
author | bunnei <bunneidev@gmail.com> | 2021-05-07 23:30:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 23:30:17 -0700 |
commit | faa067f175cbf5e916ed75776817f0046e6731c4 (patch) | |
tree | 8ab02a72a6e4d6578848c8da2c02af02684aeec7 /src/common/common_funcs.h | |
parent | 8acf739b3fac78d25dc60e1a7d1252c05afadd57 (diff) | |
parent | d57b12193b12f7b6e3565d29f7bc3d7584632768 (diff) |
Merge pull request #6266 from bunnei/kautoobject-refactor
Kernel Rework: Migrate kernel objects to KAutoObject
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); } \ } +#define YUZU_NON_COPYABLE(cls) \ + cls(const cls&) = delete; \ + cls& operator=(const cls&) = delete + +#define YUZU_NON_MOVEABLE(cls) \ + cls(cls&&) = delete; \ + cls& operator=(cls&&) = delete + #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. @@ -128,4 +136,19 @@ namespace Common { return u32(a) | u32(b) << 8 | u32(c) << 16 | u32(d) << 24; } +// std::size() does not support zero-size C arrays. We're fixing that. +template <class C> +constexpr auto Size(const C& c) -> decltype(c.size()) { + return std::size(c); +} + +template <class C> +constexpr std::size_t Size(const C& c) { + if constexpr (sizeof(C) == 0) { + return 0; + } else { + return std::size(c); + } +} + } // namespace Common |