rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.18k stars 441 forks source link

Add support for new property policy: 'as_reference_wrapper' #20

Closed acki-m closed 8 years ago

acki-m commented 8 years ago

Add a new property policy called: as_reference_wrapper or similar. Which should return the property as inside a std::reference_wrapper. The wrapped type can be retrieve later via type::get_wrapped_type().

This policy is similar to bind_as_ptr, however somebody might prefer a solid wrapper, instead of a raw ptr.

sbalogh commented 8 years ago

Please add a as_reference_wrapper policy like possibility to access variant_array_view elements. It would be very useful to prevent a copy of "big" elements and sub arrays.

How can we access wrapped value and conversion functions of variant with wrapped types? Value can be accessed if using instance class and instance::try_convert function, but instance conversion functions (to_string, to_int, ...) do not exist.

acki-m commented 8 years ago

@sbalogh You can already use the bind_as_ptr policy http://www.rttr.org/doc/master/structrttr_1_1policy_1_1prop.html#af18a7107143029acd396d39abfd8c94c arrays will be invoked via ptr..

regarding the 2nd are you looking for this? http://www.rttr.org/doc/master/classrttr_1_1instance.html#a8510396b6c2ab7d5d70dd5fc61fd7e35

acki-m commented 8 years ago

merged into master