-
Notifications
You must be signed in to change notification settings - Fork 13
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
[For discussion purpose] - Used unique_ptr instead of auto_ptr when c++11 is used. #29
base: master
Are you sure you want to change the base?
Conversation
Am 24.08.2015, 00:05 Uhr, schrieb Yohann Ferreira
I'd love to revert from luaponte to luabind and to use a library which is BTW, there is at least one failing test concerning "out_value" vs. Regards, Felix |
Hey @fhoefling :)
It's good to know. The only thing to consider though is that it seems required to keep the former C++ norm supported (or keep std::auto_ptr and don't use nullptr) optionally.
Here you're speaking about the mother luabind, which many are considering a dead upstream.
IMHO, @Oberon00 has done a good job in trying to keep the lib clean and import mostly bug fixes and taking care of not doing anything too experimental. So, would luabind's authors be away for good, I would rather focus on bringing improvements here. (As I'm trying to do with this current PR). In your opinion, what features would be lacking here before you would consider adoption, for instance?
k, created issue: #30 |
Since C++17 will probably remove However, your approach of using Also do not make this configurable in the CMake file (or if an issue arises that forces the offering of a user configurable "override switch" this should be done via a When that is done, the
Do you mean |
@Oberon00 I'm overwhelmed by other tasks but I'll come back here to upgrade PR eventually. Thanks for your patience! :) |
Hey guys, what's the status of this PR? |
I won't merge the pull request until the many #ifdefs are replaced with a |
Yeah, I've got some job left on this one. I didn't forget about it, but there is quite some things on my plate atm, sorry. :)
Here, I disagree, removing deprecation warnings is no cosmetic thing, especially when the c++14 norm will be the standard. |
Good point, I haven't thought about that. luabind is compiled with |
Move instead of copy smart pointers, using std::move. Add overload to get_pointer() to retrieve raw pointer. Based on Peter Colberg's patch: halmd-org@19d9a14
@@ -105,6 +105,10 @@ if(LUABIND_NO_STD_SHARED_PTR) | |||
add_definitions(-DLUABIND_NO_STD_SHARED_PTR) | |||
endif() | |||
|
|||
if(LUABIND_USE_CXX11) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead use LUABIND_NO_STD_UNIQUE_PTR to mirror LUABIND_NO_STD_SHARED_PTR? Ideally, this should also try to use BOOST_NO_CXX11_SMART_PTR
and a CMake option should only be necessary as a fallback.
Also, I think this should be in build_information.hpp
instead of being added via add_definitions
, but it's been too long ago, so I'm not completely sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this needs to be in build_information.hpp
. This PR is somehow live in Ubuntu 20.04 LTS though the ValyriaTear/luabind repo. It broke our ryzom/ryzomcore build, since luabind is built with the option, but the headers get included without LUABIND_USE_CXX11 (unless we hardcode the option in our own repo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The alternative is of course auto-detecting, and not giving the option to users.
@@ -96,7 +96,11 @@ namespace luabind { namespace detail | |||
template <class T> | |||
struct pointer_or_default<void, T> | |||
{ | |||
#ifdef LUABIND_USE_CXX11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have this #ifdef
in multiple places. I'd prefer placing it in a central header, like luabind_memory.hpp
or similar with a single namespace luabind { typedef unique_auto_ptr ...; }
.
@@ -54,7 +57,11 @@ struct construct_aux<0, T, Pointer, Signature> | |||
void* storage = self->allocate(sizeof(holder_type)); | |||
|
|||
self->set_instance(new (storage) holder_type( | |||
#ifdef LUABIND_USE_CXX11 | |||
std::move(ptr), registered_class<T>::id, naked_ptr)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly to the centralized typedef a centralized ifdefed LUABIND_MOVE
macro would be useful. Maybe it could also be a luabind::move function, but that might be overkill.
scope(scope const& other_); | ||
~scope(); | ||
|
||
scope& operator=(scope const& other_); | ||
|
||
scope& operator,(scope s); | ||
scope& operator,(const scope& s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the implementation in scope.cpp of this, I'm concerned. Was a simple def("foo", &foo), def("bar", &bar)
previously causing a double-delete?
Would scope&
without const work here, similar to https://en.cppreference.com/w/cpp/memory/auto_ptr/auto_ptr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I naively tried scope&
and the unit tests blew up on me. It looks like scope
is trying to implement its own homebrew unique_ptr
mechanism and that is all tied up in using const scope&
to trigger the complemented copy constructors to orchestrate the proper ownership transfer.
It felt like fixing this for c++03 would require some serious plumbing work. However, under c++11, implementing the proper move semantics seems to address the major use cases.
Hi @Bertram25! It seems this PR comes from your master branch? Do you still intend to merge this? If so, please see the comments above. I think you address some important things here, so I would be glad 😃 |
Hi guys, we've been looking at these patches and have applied @Bertram25 's changes along with @Oberon00 's comments to support We've also did some work to address the Please take a look when time allows. |
Hey @Oberon00 :D
(CC @endoalir for info.)
After some fiddling and some research, I manage to obtain a luabind version capable to compile without any warnings when using c++11, and that seems to run Valyria Tear rather fine, according to my latest tests... You can see the changes I made in this PR.
YET, (because nice things never comes free), it seems those changes aren't perfect according to the following issue: HoverRace/HoverRace#260
It seems the following adapted commit is also needed: halmd-org@1853787 because otherwise the following issue may happen: HoverRace/HoverRace#259
However, it seems HoverRace is using the main luabind repository and that other bugs may come into game, though. So I made this PR mainly to know what to do next in order to get a c++11-warning-free-and-functional luabind PR. Do you think my PR is enough, or do you have hints anywhere at how I should handle the issue around boost::shared_ptr vs std::shared_ptr?
Thanks a lot for your repository in any case and for your help, and best regards,