-
Notifications
You must be signed in to change notification settings - Fork 61
Add emplace_{back,front} to circular_buffer - rebased to latest develop #42
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
base: develop
Are you sure you want to change the base?
Conversation
This reverts commit 90ef625.
@AI0867 i've taken your code rebased to develop and made minor adjustments to be compatible with latest changes. |
@f9z Thank you for your efforts. I haven't had the time to set up a build environment on my current machine to do this myself. |
Looks good to me, plus it's more consistent with the circular_buffer code than the patch I proposed. |
That'd be the procedure to merge it to "develop" from here @gpascualg ? It's my first PR to boostorg. Anything else I need to do to make it happen? Thanks! |
I'm afraid I can't really help you here, as I have never done a PR to any boost library. I'd guess, though, that this should be it. |
@glenfe would it be possible to consider merging this PR? please let me know if i'd need to do anything else or approach some other boostorg maintainers. thanks! |
what was the problem with the initial replace() code? I left a comment about what I feel was observed here #15 (comment) this is an excellent PR but I would sort out the situation and possibly discard the last commit from the PR... |
@@ -1475,7 +1476,8 @@ private empty_value<Alloc> | |||
if (full()) { | |||
if (empty()) | |||
return; | |||
replace(m_last, value_type(::boost::forward<V>(value))); | |||
destroy_item(m_last); | |||
boost::allocator_construct(alloc(), boost::to_address(m_last), ::boost::forward<Args>(args)...); |
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.
This has not been compiled with BOOST_NO_CXX11_VARIADIC_TEMPLATES defined because I do not think this would compile.
There is no variadic template parameter Args (args) here
@@ -1515,7 +1518,8 @@ private empty_value<Alloc> | |||
if (empty()) | |||
return; | |||
decrement(m_first); | |||
replace(m_first, value_type(::boost::forward<V>(value))); | |||
destroy_item(m_first); | |||
boost::allocator_construct(alloc(), boost::to_address(m_first), ::boost::forward<Args>(args)...); |
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.
This has not been compiled with BOOST_NO_CXX11_VARIADIC_TEMPLATES defined because I do not think this would compile.
There is no variadic template parameter Args (args) here
@@ -1460,7 +1460,8 @@ private empty_value<Alloc> | |||
if (full()) { | |||
if (empty()) | |||
return; | |||
replace(m_last, value_type(::boost::forward<Args>(args)...)); |
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.
this line is wrong. This is your bug!
This is where the temporary object gets created.
What do you think value_type(...) is doing?
It creates a temporary object and call the replace() method that is using assignment!
Here is my take. This is a patch over branch after having reverted "replace replace() with destroy_item() + construct()" This reverts commit c4c85d7.
|
based on #15 request by AI0867