Skip to content

Commit

Permalink
improve register type
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Sep 23, 2024
1 parent d65ac3a commit 566b07f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion iguana/dynamic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ constexpr inline uint8_t ENABLE_ALL = 0x0F;

template <typename T, uint8_t ENABLE_FLAG = ENABLE_PB>
struct base_impl : public base {
base_impl() { [[maybe_unused]] static bool r = register_type<T>(); }
base_impl() {
// make sure init T before main, and can register_type before main.
[[maybe_unused]] static auto t =
ylt::reflection::internal::wrapper<T>::value;
[[maybe_unused]] static bool r = register_type<T>();
}
void to_pb(std::string& str) const override {
if constexpr ((ENABLE_FLAG & ENABLE_PB) != 0) {
to_pb_adl((iguana_adl_t*)nullptr, *(static_cast<T const*>(this)), str);
Expand Down

0 comments on commit 566b07f

Please sign in to comment.