Skip to content

Commit

Permalink
feat: add throw error when class has no target function
Browse files Browse the repository at this point in the history
  • Loading branch information
Dup4 committed Jun 29, 2022
1 parent 8f097e4 commit ab7d22b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/autowired/autowired.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,24 @@ class AutoWired {
node.func_Init = [t_ptr] {
t_ptr->Init();
};
} else if (node.options.need_init) {
throw std::runtime_error("Class has no Init() function");
}

if constexpr (internal::has_de_init_v<T>) {
node.func_DeInit = [t_ptr] {
t_ptr->DeInit();
};
} else if (node.options.need_de_init) {
throw std::runtime_error("Class has no DeInit() function");
}

if constexpr (internal::has_auto_wired_v<T>) {
node.func_AutoWired = [t_ptr] {
t_ptr->AutoWired();
};
} else if (node.options.need_auto_wired) {
throw std::runtime_error("Class has no AutoWired() function");
}

class_.emplace(name, std::move(node));
Expand Down

0 comments on commit ab7d22b

Please sign in to comment.