Derive-C
Loading...
Searching...
No Matches
require.h File Reference
#include <derive-c/core/namespace.h>
#include <derive-c/core/compiler.h>
#include <type_traits>

Go to the source code of this file.

Macros

#define DC_REQUIRE_FUNCTION(ret, func, args)
#define DC_REQUIRE_CONSTANT_TYPE_EXPR(obj, name, Type)
#define DC_REQUIRE_METHOD(ret, obj, name, args)
#define DC_REQUIRE_TYPE(obj, name)
#define DC_REQUIRE_CONSTANT(obj, name, type)

Macro Definition Documentation

◆ DC_REQUIRE_CONSTANT

#define DC_REQUIRE_CONSTANT ( obj,
name,
type )
Value:
"Method " #obj "." #name " must exist and be of type " #type)
#define DC_STATIC_ASSERT
Definition panic.h:22
#define DC_REQUIRE_CONSTANT_TYPE_EXPR(obj, name, Type)
Definition require.h:12

Definition at line 25 of file require.h.

25#define DC_REQUIRE_CONSTANT(obj, name, type) \
26 DC_STATIC_ASSERT(DC_REQUIRE_CONSTANT_TYPE_EXPR(obj, name, type), \
27 "Method " #obj "." #name " must exist and be of type " #type)

◆ DC_REQUIRE_CONSTANT_TYPE_EXPR

#define DC_REQUIRE_CONSTANT_TYPE_EXPR ( obj,
name,
Type )
Value:
std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(NS(obj, name))>>, Type>
#define NS(pre, post)
Definition namespace.h:14

Definition at line 12 of file require.h.

12 #define DC_REQUIRE_CONSTANT_TYPE_EXPR(obj, name, Type) \
13 std::is_same_v<std::remove_cv_t<std::remove_reference_t<decltype(NS(obj, name))>>, Type>

◆ DC_REQUIRE_FUNCTION

#define DC_REQUIRE_FUNCTION ( ret,
func,
args )
Value:
std::is_same_v<decltype(+func), ret(*) args>

Definition at line 11 of file require.h.

◆ DC_REQUIRE_METHOD

#define DC_REQUIRE_METHOD ( ret,
obj,
name,
args )
Value:
"Method " #obj "." #name " must exist with type " #ret " (*)" #args)
#define DC_REQUIRE_FUNCTION(ret, func, args)
Definition require.h:11

Definition at line 16 of file require.h.

16#define DC_REQUIRE_METHOD(ret, obj, name, args) \
17 DC_STATIC_ASSERT(DC_REQUIRE_FUNCTION(ret, NS(obj, name), args), \
18 "Method " #obj "." #name " must exist with type " #ret " (*)" #args)

◆ DC_REQUIRE_TYPE

#define DC_REQUIRE_TYPE ( obj,
name )
Value:
DC_STATIC_ASSERT(sizeof(NS(obj, name)) + 1)

Definition at line 23 of file require.h.