Skip to content

Commit

Permalink
Add static asserts to catch API misuse
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Feb 7, 2025
1 parent 1757cad commit 24dff3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/ariles2/members/methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
const std::string &
arilesDefaultID() const override
{
static_assert(
std::is_base_of_v<ariles2::Ariles, typename std::decay<decltype(*this)>::type>,
"Class where ARILES2_INITIALIZE is included must inherit from an ariles class.");
static const std::string name(ARILES2_DEFAULT_ID);
return (name);
}
Expand Down
3 changes: 3 additions & 0 deletions include/ariles2/members/visit_generic_parent.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
template <class t_Visitor, typename = ariles2::traits::is_visitor_t<t_Visitor>> \
void arilesVisitParents(t_Visitor &visitor, const typename t_Visitor::Parameters &parameters) \
{ \
static_assert( \
std::is_base_of_v<ariles2::Ariles, typename std::decay<decltype(*this)>::type>, \
"Class where ARILES2_INITIALIZE is included must inherit from an ariles class."); \
CPPUT_UNUSED_ARG(visitor); \
CPPUT_UNUSED_ARG(parameters); \
CPPUT_TRACE_FUNCTION; \
Expand Down

0 comments on commit 24dff3b

Please sign in to comment.