diff --git a/include/boost/circular_buffer/base.hpp b/include/boost/circular_buffer/base.hpp index 47441544..34c661e4 100644 --- a/include/boost/circular_buffer/base.hpp +++ b/include/boost/circular_buffer/base.hpp @@ -25,10 +25,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include @@ -2279,7 +2279,7 @@ private empty_value #if BOOST_CB_ENABLE_DEBUG erase_begin(n, false_type()); #else - erase_begin(n, is_scalar()); + erase_begin(n, has_trivial_destructor()); #endif } @@ -2311,7 +2311,7 @@ private empty_value #if BOOST_CB_ENABLE_DEBUG erase_end(n, false_type()); #else - erase_end(n, is_scalar()); + erase_end(n, has_trivial_destructor()); #endif } @@ -2462,7 +2462,7 @@ private empty_value #if BOOST_CB_ENABLE_DEBUG destroy_content(false_type()); #else - destroy_content(is_scalar()); + destroy_content(has_trivial_destructor()); #endif } diff --git a/test/constant_erase_test.cpp b/test/constant_erase_test.cpp index e2431be2..7a9069f2 100644 --- a/test/constant_erase_test.cpp +++ b/test/constant_erase_test.cpp @@ -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 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::pointer p4 = &cb4[0]; + cb4.erase_begin(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 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 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::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 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::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