Skip to content

Commit b3979f6

Browse files
authored
feat: better invalid cast error (#234)
1 parent 6cab2e7 commit b3979f6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ecsact/runtime/common.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ ECSACT_TYPED_ID(ecsact_system_like_id);
5454
ECSACT_TYPED_ID(ecsact_component_like_id);
5555

5656
#ifdef __cplusplus
57+
template<typename, typename>
58+
constexpr bool ecsact_id_invalid_cast_v = false;
59+
5760
template<typename To, typename From>
58-
To ecsact_id_cast(From);
61+
ECSACT_ALWAYS_INLINE To ecsact_id_cast(From) {
62+
static_assert(
63+
ecsact_id_invalid_cast_v<From, To>,
64+
"Invalid ecsact_id_cast - Incompatible ID Types"
65+
);
66+
}
67+
5968
# define ECSACT_CAST_ID_FN(From, To) \
6069
template<> \
6170
ECSACT_ALWAYS_INLINE To ecsact_id_cast<To, From>(From id) { \

0 commit comments

Comments
 (0)