From 69339b779cf9a6eca4b4901988188abcd42c94b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Br=C3=B6nnimann?= Date: Wed, 21 Jul 2004 17:23:40 +0000 Subject: [PATCH] Removed initialization from singular iterator. [SVN r23910] --- minmax/test/minmax_element_test.cpp | 30 +++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/minmax/test/minmax_element_test.cpp b/minmax/test/minmax_element_test.cpp index 5861e60..435c893 100644 --- a/minmax/test/minmax_element_test.cpp +++ b/minmax/test/minmax_element_test.cpp @@ -13,24 +13,24 @@ #include class custom { - int _M_x; + int m_x; friend bool operator<(custom const& x, custom const& y); friend std::ostream& operator<<(std::ostream& str, custom const& x); public: - explicit custom(int x = 0) : _M_x(x) {} - custom(custom const& y) : _M_x(y._M_x) {} - custom operator+(custom const& y) const { return custom(_M_x+y._M_x); } - custom& operator+=(custom const& y) { _M_x += y._M_x; return *this; } + explicit custom(int x = 0) : m_x(x) {} + custom(custom const& y) : m_x(y.m_x) {} + custom operator+(custom const& y) const { return custom(m_x+y.m_x); } + custom& operator+=(custom const& y) { m_x += y.m_x; return *this; } }; bool operator< (custom const& x, custom const& y) { - return x._M_x < y._M_x; + return x.m_x < y.m_x; } std::ostream& operator<<(std::ostream& str, custom const& x) { - str << x._M_x; + str << x.m_x; return str; } @@ -65,17 +65,17 @@ void tie(std::pair p, T3& first, T4& second) template struct less_count : std::less { typedef std::less Base; - less_count(less_count const& lc) : _M_counter(lc._M_counter) {} - less_count(int& counter) : _M_counter(counter) {} + less_count(less_count const& lc) : m_counter(lc.m_counter) {} + less_count(int& counter) : m_counter(counter) {} bool operator()(Value const& a, Value const& b) const { - ++_M_counter; + ++m_counter; return Base::operator()(a,b); } void reset() { - _M_counter = 0; + m_counter = 0; } private: - int& _M_counter; + int& m_counter; }; inline int opt_min_count(int n) { @@ -104,7 +104,7 @@ void test_minmax(CIterator first, CIterator last, int n) typedef boost::reverse_iterator RCIterator; // assume that CIterator is BidirectionalIter CIterator min, max; - RCIterator rfirst(last), rlast(first), rmin(min), rmax(max); + RCIterator rfirst(last), rlast(first), rmin, rmax; int counter = 0; less_count lc(counter); @@ -114,6 +114,7 @@ void test_minmax(CIterator first, CIterator last, int n) CHECK_EQUAL_ITERATORS( min, std::min_element(first, last), first ); CHECK_EQUAL_ITERATORS( max, std::max_element(first, last), first ); + // second version, comp function object (keeps a counter!) lc.reset(); tie( boost::minmax_element(first, last, lc), min, max ); @@ -140,6 +141,7 @@ void test_minmax(CIterator first, CIterator last, int n) tie( boost::last_min_last_max_element(first, last), min, max ); CHECK_EQUAL_ITERATORS( min, boost::last_min_element(first, last), first ); CHECK_EQUAL_ITERATORS( max, boost::last_max_element(first, last), first ); + // second version, comp function object (keeps a counter!) lc.reset(); min = boost::first_min_element(first, last, lc); @@ -184,7 +186,7 @@ void test_container(Iterator first, Iterator last, int n, Container* dummy = 0 ) } template -void test_range(Iterator first, Iterator last, int n, char* name) +void test_range(Iterator first, Iterator last, int n, char* /* name */) { typedef typename std::iterator_traits::value_type Value; // Test various containers with these values