-
Notifications
You must be signed in to change notification settings - Fork 442
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
rttr::variant why only const getter? #108
Labels
Comments
Regarding Mhm... mabye I can add a support for moving values out. However, the |
acki-m
added a commit
to acki-m/rttr
that referenced
this issue
Mar 5, 2018
Added 4 overloads of the method "variant_cast" In order to move values out, to return values by reference or to return a pointer to the underlying values, when the type does match: template<class T> T variant_cast(variant&& operand); template<class T> T variant_cast(variant& operand); template<class T> T variant_cast(const variant& operand); template<class T> const T* variant_cast(const variant* operand) RTTR_NOEXCEPT; template<class T> T* variant_cast(variant* operand) RTTR_NOEXCEPT; Additionally: - added non-const version of variant::get_value() - fixed copy-right year in root CMakeLists.txt file Fixes rttrorg#108
acki-m
added a commit
that referenced
this issue
Mar 8, 2018
* Added global "variant_cast" method Added 4 overloads of the method "variant_cast" In order to move values out, to return values by reference or to return a pointer to the underlying values, when the type does match: template<class T> T variant_cast(variant&& operand); template<class T> T variant_cast(variant& operand); template<class T> T variant_cast(const variant& operand); template<class T> const T* variant_cast(const variant* operand) RTTR_NOEXCEPT; template<class T> T* variant_cast(variant* operand) RTTR_NOEXCEPT; Additionally: - added non-const version of variant::get_value() - fixed copy-right year in root CMakeLists.txt file Fixes #108
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why can we not get the object as non-const reference?
I could use the policy as
rttr::policy::ctor::as_std_shared_ptr
orrttr::policy::ctor::as_raw_ptr
.then get the pointer (
MyMessage* & const
) . Is there a reason, why it returns aconst T&
?Would it be possibe to have a policy which constructs a
std::unique_ptr
? Probably its not so easy asstd::move
is needed internally when we get the object.-> SFINAE which enables a
get_value
function whichstd::move
s the stuff out?Background:
I try to use this rttr stuff for serializing/deserializing messages, (serialize the type, here the
MyMessage
string, and the payload)The text was updated successfully, but these errors were encountered: