diff --git a/base/base_tests/stl_helpers_test.cpp b/base/base_tests/stl_helpers_test.cpp index 23246beeff..335e7fc515 100644 --- a/base/base_tests/stl_helpers_test.cpp +++ b/base/base_tests/stl_helpers_test.cpp @@ -20,24 +20,24 @@ private: int m_v; }; -template class TContainer> +template class Cont> void TestSortUnique() { { - TContainer> actual = {1, 2, 1, 4, 3, 5, 2, 7, 1}; + Cont> actual = {1, 2, 1, 4, 3, 5, 2, 7, 1}; my::SortUnique(actual); - TContainer> const expected = {1, 2, 3, 4, 5, 7}; + Cont> const expected = {1, 2, 3, 4, 5, 7}; TEST_EQUAL(actual, expected, ()); } { using TValue = int; using TPair = pair; - TContainer> d = + Cont> d = {{1, 22}, {2, 33}, {1, 23}, {4, 54}, {3, 34}, {5, 23}, {2, 23}, {7, 32}, {1, 12}}; - my::SortUnique(d, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first)); + my::SortUnique(d, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first)); - TContainer> const expected = {1, 2, 3, 4, 5, 7}; + Cont> const expected = {1, 2, 3, 4, 5, 7}; TEST_EQUAL(d.size(), expected.size(), ()); for (int i = 0; i < d.size(); ++i) TEST_EQUAL(d[i].first, expected[i], (i)); @@ -45,39 +45,39 @@ void TestSortUnique() { using TValue = double; using TPair = pair; - TContainer> d = + Cont> d = {{0.5, 11}, {1000.99, 234}, {0.5, 23}, {1234.56789, 54}, {1000.99, 34}}; - my::SortUnique(d, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first)); + my::SortUnique(d, my::LessBy(&TPair::first), my::EqualsBy(&TPair::first)); - TContainer> const expected = {0.5, 1000.99, 1234.56789}; + Cont> const expected = {0.5, 1000.99, 1234.56789}; TEST_EQUAL(d.size(), expected.size(), ()); for (int i = 0; i < d.size(); ++i) TEST_EQUAL(d[i].first, expected[i], (i)); } } -template class TContainer> +template class Cont> void TestEqualsBy() { { using TValue = pair; - TContainer> actual = {{1, 2}, {1, 3}, {2, 100}, {3, 7}, {3, 8}, {2, 500}}; + Cont> actual = {{1, 2}, {1, 3}, {2, 100}, {3, 7}, {3, 8}, {2, 500}}; actual.erase(unique(actual.begin(), actual.end(), my::EqualsBy(&TValue::first)), actual.end()); - TContainer> const expected = {{1, 2, 3, 2}}; + Cont> const expected = {{1, 2, 3, 2}}; TEST_EQUAL(expected.size(), actual.size(), ()); for (size_t i = 0; i < actual.size(); ++i) TEST_EQUAL(expected[i], actual[i].first, ()); } { - TContainer> actual; + Cont> actual; for (auto const v : {0, 0, 1, 2, 2, 0}) actual.emplace_back(v); actual.erase(unique(actual.begin(), actual.end(), my::EqualsBy(&Int::Get)), actual.end()); - TContainer> const expected = {{0, 1, 2, 0}}; + Cont> const expected = {{0, 1, 2, 0}}; TEST_EQUAL(expected.size(), actual.size(), ()); for (size_t i = 0; i < actual.size(); ++i) TEST_EQUAL(expected[i], actual[i].Get(), ()); @@ -117,20 +117,12 @@ UNIT_TEST(LessBy) UNIT_TEST(EqualsBy_VectorTest) { TestEqualsBy(); -} - -UNIT_TEST(EqualsBy_DequeTest) -{ TestEqualsBy(); } UNIT_TEST(SortUnique_VectorTest) { TestSortUnique(); -} - -UNIT_TEST(SortUnique_DequeTest) -{ TestSortUnique(); } } // namespace diff --git a/base/stl_helpers.hpp b/base/stl_helpers.hpp index 99ff06305a..98d5b64c69 100644 --- a/base/stl_helpers.hpp +++ b/base/stl_helpers.hpp @@ -82,8 +82,8 @@ struct Equals } // namespace impl // Sorts and removes duplicate entries from |c|. -template > class Container> -void SortUnique(Container & c) +template > class Cont> +void SortUnique(Cont & c) { sort(c.begin(), c.end()); c.erase(unique(c.begin(), c.end()), c.end()); @@ -92,18 +92,17 @@ void SortUnique(Container & c) // Sorts according to |comp| and removes duplicate entries according to |pred| from |c|. // Note. If several entries are equal according to |pred| an arbitrary entry of them // is left in |c| after a call of this function. -template > class Container, - typename TLess, typename TEquals> -void SortUnique(Container & c, TLess && less, TEquals && equals) +template +void SortUnique(Cont & c, Less && less, Equals && equals) { - sort(c.begin(), c.end(), forward(less)); - c.erase(unique(c.begin(), c.end(), forward(equals)), c.end()); + sort(c.begin(), c.end(), forward(less)); + c.erase(unique(c.begin(), c.end(), forward(equals)), c.end()); } -template > class Container, class TFn> -void EraseIf(Container & c, TFn && fn) +template +void EraseIf(Cont & c, Fn && fn) { - c.erase(remove_if(c.begin(), c.end(), forward(fn)), c.end()); + c.erase(remove_if(c.begin(), c.end(), forward(fn)), c.end()); } // Creates a comparer being able to compare two instances of class C diff --git a/std/auto_ptr.hpp b/std/auto_ptr.hpp index 565d835a22..311f4643ab 100644 --- a/std/auto_ptr.hpp +++ b/std/auto_ptr.hpp @@ -5,8 +5,8 @@ #endif #include -using std::auto_ptr; using std::allocator; +using std::auto_ptr; #ifdef DEBUG_NEW #define new DEBUG_NEW