You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.4 KiB

#ifndef _MACROS_HH
#define _MACROS_HH
#ifdef __cplusplus
#include <type_traits>
#include <utility>
#ifndef NOTHING
#define NOTHING
#endif
#define _DEFINE_CLASS(NAME, constexpr, virtual, noexcept, dtor, copy, move, copy_assign, move_assign, ...)
constexpr NAME(NAME &&) noexcept move
constexpr NAME(NAME const&) noexcept copy
constexpr NAME & operator=(NAME &&) noexcept move_assign
constexpr NAME & operator=(NAME const&) noexcept copy_assign
constexpr virtual ~NAME() dtor
#define DEFINE_INTERFACE(...) \
_DEFINE_CLASS(__VA_ARGS__, constexpr, virtual, noexcept, =default, =default;, =default;, =default;, =default;, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING)
#define DEFINE_MOVE_INTERFACE(...) \
_DEFINE_CLASS(__VA_ARGS__, constexpr, virtual, noexcept, =default, =delete;, =default;, =delete;, =default;, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING, NOTHING)
#define FORWARD(T) ::std::forward<decltype(T)>(T)
#define $L(...) { return __VA_ARGS__; }
#define $L_(...) { __VA_ARGS__; }
//#define $CLASS
#define $impl $CLASS::
#define $ctor $CLASS::$CLASS
#define $dtor $CLASS::~$CLASS
#define $ctor_cpoy(n) $ctor($CLASS const& n)
#define $ctor_move(n) $ctor($CLASS && n)
#define $assign $CLASS & operator=
#define $assign_copy(n) $CLASS & $CLASS::operator=($CLASS const& n)
#define $assign_move(n) $CLASS & $CLASS::operator=($CLASS && n)
#elif defined(DEBUG)
#warn "Included C++ header to C TU"
#endif
#endif