fix build after for_ was changed to use auto.
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 20 Oct 2011 21:43:38 +0000 (23:43 +0200)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Thu, 20 Oct 2011 21:43:38 +0000 (23:43 +0200)
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
tests/zypp/Selectable_test.cc

index a73505e..1f9e3a3 100644 (file)
@@ -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] );
index cd5072a..abd03a8 100644 (file)
@@ -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;
       }
     }