Skip to content

Commit

Permalink
feat: better invalid cast error (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored Apr 17, 2024
1 parent 6cab2e7 commit b3979f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ecsact/runtime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ ECSACT_TYPED_ID(ecsact_system_like_id);
ECSACT_TYPED_ID(ecsact_component_like_id);

#ifdef __cplusplus
template<typename, typename>
constexpr bool ecsact_id_invalid_cast_v = false;

template<typename To, typename From>
To ecsact_id_cast(From);
ECSACT_ALWAYS_INLINE To ecsact_id_cast(From) {
static_assert(
ecsact_id_invalid_cast_v<From, To>,
"Invalid ecsact_id_cast - Incompatible ID Types"
);
}

# define ECSACT_CAST_ID_FN(From, To) \
template<> \
ECSACT_ALWAYS_INLINE To ecsact_id_cast<To, From>(From id) { \
Expand Down

0 comments on commit b3979f6

Please sign in to comment.