Repository navigation
Allow trivially destructible types use constant erase #52
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
Open
ldeng-ustc
wants to merge
1
commit into
boostorg:develop
Choose a base branch
from
ldeng-ustc:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+73
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,31 @@ void erase_begin_test() { | |
| BOOST_TEST(cb3[0] == 4); | ||
| BOOST_TEST(cb3[1] == 5); | ||
| BOOST_TEST(cb3[2] == 6); | ||
|
|
||
|
|
||
| circular_buffer<MyDefaultConstructible> cb4(5); | ||
| cb4.push_back(1); | ||
| cb4.push_back(2); | ||
| cb4.push_back(3); | ||
| cb4.push_back(4); | ||
| cb4.push_back(5); | ||
| cb4.push_back(6); | ||
|
|
||
|
|
||
| circular_buffer<MyDefaultConstructible>::pointer p4 = &cb4[0]; | ||
| cb4.erase_begin(5); | ||
| BOOST_TEST(cb4.empty()); | ||
| BOOST_TEST(p4->m_n == 2); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests only work in non-debug builds. Reading through p4 after erasing only works without BOOST_CB_ENABLE_DEBUG, because the debug build overwrites erased memory. |
||
| BOOST_TEST((p4 + 1)->m_n == 3); | ||
| BOOST_TEST((p4 + 2)->m_n == 4); | ||
| BOOST_TEST((p4 + 3)->m_n == 5); | ||
| BOOST_TEST((p4 - 1)->m_n == 6); | ||
|
|
||
| cb4.push_back(10); | ||
| cb4.push_back(11); | ||
| BOOST_TEST(cb4.size() == 2); | ||
| BOOST_TEST(cb4[0].m_n == 10); | ||
| BOOST_TEST(cb4[1].m_n == 11); | ||
| } | ||
|
|
||
| void erase_end_test() { | ||
|
|
@@ -127,6 +152,31 @@ void erase_end_test() { | |
| BOOST_TEST(cb3[0] == 2); | ||
| BOOST_TEST(cb3[1] == 3); | ||
| BOOST_TEST(cb3[2] == 4); | ||
|
|
||
|
|
||
| circular_buffer<MyDefaultConstructible> cb4(5); | ||
| cb4.push_back(1); | ||
| cb4.push_back(2); | ||
| cb4.push_back(3); | ||
| cb4.push_back(4); | ||
| cb4.push_back(5); | ||
| cb4.push_back(6); | ||
|
|
||
| circular_buffer<MyDefaultConstructible>::pointer p4 = &cb4[0]; | ||
|
|
||
| cb4.erase_end(5); | ||
| BOOST_TEST(cb4.empty()); | ||
| BOOST_TEST(p4->m_n == 2); | ||
| BOOST_TEST((p4 + 1)->m_n == 3); | ||
| BOOST_TEST((p4 + 2)->m_n == 4); | ||
| BOOST_TEST((p4 + 3)->m_n == 5); | ||
| BOOST_TEST((p4 - 1)->m_n == 6); | ||
|
|
||
| cb4.push_back(10); | ||
| cb4.push_back(11); | ||
| BOOST_TEST(cb4.size() == 2); | ||
| BOOST_TEST(cb4[0].m_n == 10); | ||
| BOOST_TEST(cb4[1].m_n == 11); | ||
| } | ||
|
|
||
| void clear_test() { | ||
|
|
@@ -170,6 +220,25 @@ void clear_test() { | |
| cb3.clear(); | ||
|
|
||
| BOOST_TEST(cb3.empty()); | ||
|
|
||
| circular_buffer<MyDefaultConstructible> cb4(5); | ||
| cb4.push_back(1); | ||
| cb4.push_back(2); | ||
| cb4.push_back(3); | ||
| cb4.push_back(4); | ||
| cb4.push_back(5); | ||
| cb4.push_back(6); | ||
|
|
||
| circular_buffer<MyDefaultConstructible>::pointer p4 = &cb4[0]; | ||
|
|
||
| cb4.clear(); | ||
|
|
||
| BOOST_TEST(cb4.empty()); | ||
| BOOST_TEST(p4->m_n == 2); | ||
| BOOST_TEST((p4 + 1)->m_n == 3); | ||
| BOOST_TEST((p4 + 2)->m_n == 4); | ||
| BOOST_TEST((p4 + 3)->m_n == 5); | ||
| BOOST_TEST((p4 - 1)->m_n == 6); | ||
| } | ||
|
|
||
| // test main | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Blank lines in the tests: the cb4 blocks in erase_begin_test and erase_end_test are preceded by two blank lines, and the erase_begin_test block also has two blank lines after its last push_back. The rest of the file uses single blank lines. The blank line before p4 = &cb4[0] also differs between the erase_begin and erase_end blocks.