-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Intrusive" Syntax and member initialization #13
Comments
I agree, that would be great, and it is an oversight. One thing that concerns me is, if the
So I'd be tempted to make the with-initializer syntax like this:
What do you think? |
This should also work even if not ideal with struct my_type {
BEGIN_VISITABLES(my_type);
VISITABLE(int, a, 0);
VISITABLE(float, b, 0.0);
VISITABLE(std::string, c);
VISITABLE(std::atomic<int>, d, {0});
END_VISITABLES;
}; What do you think? |
We can always think about having struct my_type {
BEGIN_VISITABLES(my_type);
VISITABLE_INIT(int, a, 0);
VISITABLE_INIT(float, b, 0.0);
VISITABLE(std::string, c);
VISITABLE_LIST(std::atomic<int>, d, {0});
END_VISITABLES;
}; |
From my point of view the difference is "copy initialization" (using an It makes a difference if the class is not copyable or something What would you think about:
I could also make it so that |
Yes! You totally got my point. I just called them differently: I wouldn't bother too much about merging If you implement this I will be able to use it in my project! Thanks Note: I believe this is stopping many from using it because the reason to use reflection is most likely because the struct is big, for the same reason you dont want to manually write a constructor that initialize with default values, but you cannot afford to leave the struct uninitialized... |
I agree, thanks for bringing this up! |
Could you let me know when the new feature is in place? Thank you |
Yeah will do, sorry I've been super busy! |
Just to let you know, I started working on this, going to make some tests and run on some more compilers just to make sure there's no problem :) |
Thanks. Let me know if you want me to try it as well before you merge the change. |
@cbeck88 I was looking for a simple standalone library to interface with some large structs (serialization, exposing to gui, ...) and finally came across your's, which looks fantastic, except for the missing initialization in the intrusive syntax. I'm sure you are probably busy, but did you manage to work on this? |
Hey im really sorry, I just got married on Jan 4th. I will make time for this really soon! Someone once told me, love is the primary obstacle to many open source software projects... 😅 |
Haha, thanks for the quick reply and congratulations 🍾! No worries, there are more important things in life than initializer lists 😆. |
In the meantime this has been working well for me: #define VISITABLE_INIT(TYPE, NAME, VALUE) \
TYPE NAME = VALUE; \
struct VISIT_STRUCT_MAKE_MEMBER_NAME(NAME) : \
visit_struct::detail::member_ptr_helper<VISIT_STRUCT_CURRENT_TYPE, \
TYPE, \
&VISIT_STRUCT_CURRENT_TYPE::NAME> \
{ \
static VISIT_STRUCT_CONSTEXPR const ::visit_struct::detail::char_array<sizeof(#NAME)> & member_name() { \
return #NAME; \
} \
}; \
static inline ::visit_struct::detail::Append_t<VISIT_STRUCT_GET_REGISTERED_MEMBERS, \
VISIT_STRUCT_MAKE_MEMBER_NAME(NAME)> \
Visit_Struct_Get_Visitables__(::visit_struct::detail::Rank<VISIT_STRUCT_GET_REGISTERED_MEMBERS::size + 1>); \
static_assert(true, "") |
Also added |
Hi, is it possible to to member initialization while using the "Intrusive" Syntax?
Something like the following:
The text was updated successfully, but these errors were encountered: