rttrorg / rttr

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

What about have "as_make_std_shared_ptr"? #73

Closed OverMalo closed 7 years ago

OverMalo commented 7 years ago

Hi,

The policy as_std_shared_ptr does not using std::make_shared to can declare protected or private constructor.. but it would be great to use make_shared with the classes without this need.

Perhaps...a new policy called..."as_make_std_shared_ptr" limited only to public constructor.

What do you think?

The documentation are incorrect...

PD: I could you do a pull request with this feature.

acki-m commented 7 years ago

I don't see the big benefit (one less new call) of using std::make_shared instead of not able to register private or protected ctors. And by the way when you like to use std::make_shared register it directly. eg.:

 rttr::registration::class_<point2d>("point2d")
        .constructor(std::make_shared<point2d>)();

You are writing actual less code, then with the policy.