Add emplace_{back,front} to circular_buffer - rebased to latest develop#42
Add emplace_{back,front} to circular_buffer - rebased to latest develop#42f9z wants to merge 7 commits intoboostorg:developfrom
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... |
| 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.
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
| 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.
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
| if (full()) { | ||
| if (empty()) | ||
| return; | ||
| replace(m_last, value_type(::boost::forward<Args>(args)...)); |
There was a problem hiding this comment.
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