From e12b99a648396493f380de43c2dd101ddfc68709 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 20 Oct 2011 23:43:38 +0200 Subject: [PATCH] fix build after for_ was changed to use auto. the construct for_(i, 0UL, v.size()) did not build becasue size_t is not 0UL on all systems. Replacing 0 with a size_t cast or the container size_type would defeat the purpose of using a for_ construct. For iterations where the index is needed a classic for is shorter. Also the question remains open whether for_ is needed now that C++11 provides the for (auto x : container) construct. --- tests/zypp/PoolQuery_test.cc | 4 ++-- tests/zypp/Selectable_test.cc | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/zypp/PoolQuery_test.cc b/tests/zypp/PoolQuery_test.cc index a73505e..1f9e3a3 100644 --- a/tests/zypp/PoolQuery_test.cc +++ b/tests/zypp/PoolQuery_test.cc @@ -704,9 +704,9 @@ BOOST_AUTO_TEST_CASE(pool_query_equal) v.push_back( q ); } - for_( li, 0LU, v.size() ) + for (size_t li = 0; li < v.size(); ++li) { - for_( ri, 0LU, v.size() ) + for (size_t ri = 0; ri < v.size(); ++ri) { COUT << li << " <> " << ri << endl; bool equal( v[li] == v[ri] ); diff --git a/tests/zypp/Selectable_test.cc b/tests/zypp/Selectable_test.cc index cd5072a..abd03a8 100644 --- a/tests/zypp/Selectable_test.cc +++ b/tests/zypp/Selectable_test.cc @@ -264,21 +264,20 @@ struct StatusCombination } bool next() { - for_( i, 0LU, _items.size() ) + for (auto i : _items) { - switch ( _items[i].status().getTransactValue() ) + switch ( i.status().getTransactValue() ) { case ResStatus::KEEP_STATE: - _items[i].status().setTransactValue( ResStatus::LOCKED, ResStatus::USER ); + i.status().setTransactValue( ResStatus::LOCKED, ResStatus::USER ); return true; break; case ResStatus::LOCKED: - _items[i].status().setTransactValue( ResStatus::TRANSACT, ResStatus::USER ); + i.status().setTransactValue( ResStatus::TRANSACT, ResStatus::USER ); return true; break; case ResStatus::TRANSACT: - _items[i].status().setTransactValue( ResStatus::KEEP_STATE, ResStatus::USER ); - // increment next i + i.status().setTransactValue( ResStatus::KEEP_STATE, ResStatus::USER ); break; } } -- 2.7.4