diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-21 14:20:16 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-21 14:20:16 +0200 |
| commit | 7a38c6c434e03256d9e9fbff87516b3ad1e3958a (patch) | |
| tree | 2cb34a9613fc7f50a6bd7dc0d03eca448e3f5567 /compat | |
| parent | 9a0d8a428b21a77272380009d97436b0a5f20d8c (diff) | |
macro shenanigans
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/assert.hpp | 8 | ||||
| -rw-r--r-- | compat/defs.hpp | 30 |
2 files changed, 30 insertions, 8 deletions
diff --git a/compat/assert.hpp b/compat/assert.hpp index 44b401fa..c91dd785 100644 --- a/compat/assert.hpp +++ b/compat/assert.hpp @@ -47,6 +47,14 @@ #define fm_log(...) fm_EMIT_DEBUG("", __VA_ARGS__) #define fm_debug(...) fm_EMIT_DEBUG("", __VA_ARGS__) +#define fm_warn_once(...) do { \ + static bool _fm_once_flag = false; \ + if (!_fm_once_flag) { \ + _fm_once_flag = true; \ + fm_warn(__VA_ARGS__); \ + } \ + } while (false) + #ifdef __GNUG__ # pragma GCC diagnostic pop #endif diff --git a/compat/defs.hpp b/compat/defs.hpp index 632bafe5..1bd0f181 100644 --- a/compat/defs.hpp +++ b/compat/defs.hpp @@ -1,19 +1,33 @@ #pragma once #ifdef _MSC_VER -# define FUNCTION_NAME __FUNCSIG__ +# define fm_FUNCTION_NAME __FUNCSIG__ #else -# define FUNCTION_NAME __PRETTY_FUNCTION__ +# define fm_FUNCTION_NAME __PRETTY_FUNCTION__ #endif -#define progn(...) [&]{__VA_ARGS__;}() +#define fm_begin(...) [&]{__VA_ARGS__}() -#define DECLARE_DEPRECATED_COPY_ASSIGNMENT(type) \ - [[deprecated]] type(const type&) = default; \ - [[deprecated]] type& operator=(const type&) = default +#define fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(type) \ + [[deprecated]] type(const type&) noexcept = default; \ + [[deprecated]] type& operator=(const type&) noexcept = default -#define DECLARE_DELETED_COPY_ASSIGNMENT(type) \ - type(const type&) = delete; \ +#define fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type) \ + constexpr type(const type&) noexcept = default; \ + constexpr type& operator=(const type&) noexcept = default + +#define fm_DECLARE_DELETED_COPY_ASSIGNMENT(type) \ + type(const type&) = delete; \ type& operator=(const type&) = delete +#define fm_DECLARE_DELETED_MOVE_ASSIGNMENT(type) \ + [[deprecated]] type(type&&) = delete; \ + [[deprecated]] type& operator=(type&&) = delete + +#define fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type) \ + constexpr type(type&&) noexcept = default; \ + constexpr type& operator=(type&&) noexcept = default +#define fm_DECLARE_DEFAULT_MOVE_COPY_ASSIGNMENTS(type) \ + fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type); \ + fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type) |
