Skip to content

Commit a3ee939

Browse files
Add ARCHETYPE_CHECK
1 parent 4413e4a commit a3ee939

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

include/archetype/archetype.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ template <class BASE> class identity : public BASE {}; // derived is the base
3232
#define ARCHETYPE_METHOD(ret, name, ...) \
3333
(ARCH_PP_UNIQUE_NAME(name), ret, name, __VA_ARGS__)
3434

35+
#define ARCHETYPE_CHECK(ARCHETYPE, TYPE)\
36+
static_assert(ARCHETYPE::check<TYPE>::value, STRINGIFY(TYPE must satisfy ARCHETYPE::check));
37+
3538
#define ARCHETYPE_DEFINE(NAME, METHODS) \
3639
struct NAME { \
3740
NAME() = delete; \
@@ -58,6 +61,7 @@ template <class BASE> class identity : public BASE {}; // derived is the base
5861
\
5962
protected: \
6063
template <typename T> void bind(T &t) { \
64+
ARCHETYPE_CHECK(NAME, T) \
6165
this->B::bind(t); \
6266
ARCH_PP_EXPAND_CALLSTUB_ASSIGNMENTS(METHODS) \
6367
} \
@@ -354,7 +358,7 @@ public: \
354358
#define ARCH_PP_COMMA_IF_ARGS_1 ,
355359
#define ARCH_PP_COMMA_IF_ARGS_0
356360

357-
// utility (conARCH_PP_CATenation)
361+
// utility (concatenation)
358362
#define M_CONC(A, B) M_CONC_(A, B)
359363
#define M_CONC_(A, B) A##B
360364

0 commit comments

Comments
 (0)