Commit 8e45602d authored by snuverink_j's avatar snuverink_j
Browse files

replace usage of boost foreach with c++11 range for-loop

parent f3be7763
...@@ -4,9 +4,6 @@ ...@@ -4,9 +4,6 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include "Comm/Splitter/SplitStrategy.h" #include "Comm/Splitter/SplitStrategy.h"
typedef std::vector<int> coordinates_t; typedef std::vector<int> coordinates_t;
...@@ -52,12 +49,12 @@ public: ...@@ -52,12 +49,12 @@ public:
} }
// 3. Compute centroids of partition and assign master // 3. Compute centroids of partition and assign master
foreach(region_t & region, regions_) { for(region_t & region : regions_) {
computeCentroid(region); computeCentroid(region);
} }
// 4. Create communicator groups // 4. Create communicator groups
foreach(region_t & region, regions_) { for(region_t & region : regions_) {
bool is_worker = false; bool is_worker = false;
coordinates_t iter = region.origin; coordinates_t iter = region.origin;
...@@ -107,7 +104,7 @@ protected: ...@@ -107,7 +104,7 @@ protected:
int split_in_direction = 0; int split_in_direction = 0;
int max_ext_dir = 0; int max_ext_dir = 0;
foreach(region_t region, regions_) { for(region_t region : regions_) {
for(int dim = 0; dim < topology_.getNumDimensions(); dim++) { for(int dim = 0; dim < topology_.getNumDimensions(); dim++) {
if(region.extensions[dim] > max_ext_dir) { if(region.extensions[dim] > max_ext_dir) {
split_in_direction = dim; split_in_direction = dim;
......
...@@ -5,9 +5,6 @@ ...@@ -5,9 +5,6 @@
#include "Comm/Splitter/SplitStrategy.h" #include "Comm/Splitter/SplitStrategy.h"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include <boost/random/mersenne_twister.hpp> #include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp> #include <boost/random/uniform_int_distribution.hpp>
...@@ -41,7 +38,7 @@ public: ...@@ -41,7 +38,7 @@ public:
int num_assigned_masters = 0; int num_assigned_masters = 0;
// assign workers uniform at random to each master // assign workers uniform at random to each master
foreach(int master_pid, master_pids) { for(int master_pid : master_pids) {
if(master_pid == rank_) role_ = Role_t.POLLER; if(master_pid == rank_) role_ = Role_t.POLLER;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "Expression/Parser/skipper.hpp" #include "Expression/Parser/skipper.hpp"
#include "Expression/Parser/function.hpp" #include "Expression/Parser/function.hpp"
#include <boost/foreach.hpp>
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <boost/variant/get.hpp> #include <boost/variant/get.hpp>
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "boost/variant/get.hpp" #include "boost/variant/get.hpp"
#include "boost/variant/variant.hpp" #include "boost/variant/variant.hpp"
#include "boost/smart_ptr.hpp" #include "boost/smart_ptr.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include "Util/Types.h" #include "Util/Types.h"
#include "Util/OptPilotException.h" #include "Util/OptPilotException.h"
...@@ -43,7 +41,7 @@ struct FromFile { ...@@ -43,7 +41,7 @@ struct FromFile {
return boost::make_tuple(0.0, false); return boost::make_tuple(0.0, false);
} }
foreach(double obj_value, values_) for(double obj_value : values_)
sum += obj_value; sum += obj_value;
return boost::make_tuple(sum, is_valid); return boost::make_tuple(sum, is_valid);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
=============================================================================*/ =============================================================================*/
#include "evaluator.hpp" #include "evaluator.hpp"
#include <boost/foreach.hpp>
#include <boost/variant/apply_visitor.hpp> #include <boost/variant/apply_visitor.hpp>
namespace client { namespace code_gen { namespace client { namespace code_gen {
...@@ -101,8 +100,7 @@ namespace client { namespace code_gen { ...@@ -101,8 +100,7 @@ namespace client { namespace code_gen {
bool StackEvaluator::operator()(ast::function_call const& x) { bool StackEvaluator::operator()(ast::function_call const& x) {
BOOST_FOREACH(ast::function_call_argument const& arg, x.args) { for(ast::function_call_argument const& arg : x.args) {
if (!boost::apply_visitor(*this, arg)) if (!boost::apply_visitor(*this, arg))
return false; return false;
} }
...@@ -135,7 +133,7 @@ namespace client { namespace code_gen { ...@@ -135,7 +133,7 @@ namespace client { namespace code_gen {
if (!boost::apply_visitor(*this, x.first)) if (!boost::apply_visitor(*this, x.first))
return false; return false;
BOOST_FOREACH(ast::operation const& oper, x.rest) { for(ast::operation const& oper : x.rest) {
if (!(*this)(oper)) if (!(*this)(oper))
return false; return false;
} }
......
...@@ -60,8 +60,7 @@ namespace client { namespace code_gen ...@@ -60,8 +60,7 @@ namespace client { namespace code_gen
bool operator()(ast::function_call const& x) { bool operator()(ast::function_call const& x) {
functions_.insert(x.function_name.name); functions_.insert(x.function_name.name);
BOOST_FOREACH(ast::function_call_argument const& arg, x.args) { for(ast::function_call_argument const& arg: x.args) {
if (!boost::apply_visitor(*this, arg)) if (!boost::apply_visitor(*this, arg))
return false; return false;
//if (!(*this)(arg)) //if (!(*this)(arg))
...@@ -75,7 +74,7 @@ namespace client { namespace code_gen ...@@ -75,7 +74,7 @@ namespace client { namespace code_gen
if (!boost::apply_visitor(*this, x.first)) if (!boost::apply_visitor(*this, x.first))
return false; return false;
BOOST_FOREACH(ast::operation const& oper, x.rest) { for(ast::operation const& oper: x.rest) {
if (!(*this)(oper)) if (!(*this)(oper))
return false; return false;
} }
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include "boost/variant/get.hpp" #include "boost/variant/get.hpp"
#include "boost/variant/variant.hpp" #include "boost/variant/variant.hpp"
#include "boost/smart_ptr.hpp" #include "boost/smart_ptr.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include "Util/Types.h" #include "Util/Types.h"
#include "Util/SDDSReader.h" #include "Util/SDDSReader.h"
...@@ -58,7 +56,7 @@ struct SumErrSq { ...@@ -58,7 +56,7 @@ struct SumErrSq {
double sum = 0; double sum = 0;
foreach(Measurement measurement, measurements_) { for(Measurement measurement : measurements_) {
double sim_value = 0.0; double sim_value = 0.0;
try { try {
sim_stats->getInterpolatedValue( sim_stats->getInterpolatedValue(
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include <sys/stat.h> #include <sys/stat.h>
#include "boost/algorithm/string.hpp" #include "boost/algorithm/string.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp> #include <boost/archive/text_iarchive.hpp>
...@@ -209,7 +207,7 @@ bool FixedPisaNsga2<CO, MO>::onMessage(MPI_Status status, size_t length) { ...@@ -209,7 +207,7 @@ bool FixedPisaNsga2<CO, MO>::onMessage(MPI_Status status, size_t length) {
delete[] buffer; delete[] buffer;
std::set<unsigned int> new_state_ids; std::set<unsigned int> new_state_ids;
foreach(individual ind, new_states) { for (individual ind : new_states) {
// only insert individual if not already in population // only insert individual if not already in population
if(variator_m->population()->isRepresentedInPopulation(ind.genes)) if(variator_m->population()->isRepresentedInPopulation(ind.genes))
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include <fstream> #include <fstream>
#include "boost/smart_ptr.hpp" #include "boost/smart_ptr.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include "extlib/wfgHypervolume/hypervolume.h" #include "extlib/wfgHypervolume/hypervolume.h"
...@@ -116,7 +114,7 @@ public: ...@@ -116,7 +114,7 @@ public:
void commit_individuals(std::set<unsigned int> ids) { void commit_individuals(std::set<unsigned int> ids) {
foreach(unsigned int id, ids) { for (unsigned int id : ids) {
//std::cout << "--+ committing id = " << id << "\xd"; //std::cout << "--+ committing id = " << id << "\xd";
individual ind = get_staging(id); individual ind = get_staging(id);
individuals.insert(ind_t(id, ind)); individuals.insert(ind_t(id, ind));
...@@ -150,7 +148,7 @@ public: ...@@ -150,7 +148,7 @@ public:
//XXX: currently O(n): add a fast look-up table? //XXX: currently O(n): add a fast look-up table?
bool isRepresentedInPopulation(genes_t ind_genes) { bool isRepresentedInPopulation(genes_t ind_genes) {
foreach(ind_t ind, individuals) { for(ind_t ind : individuals) {
if( ind_genes == ind.second->genes ) if( ind_genes == ind.second->genes )
return true; return true;
} }
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#include "boost/smart_ptr.hpp" #include "boost/smart_ptr.hpp"
#include "boost/tuple/tuple.hpp" #include "boost/tuple/tuple.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
namespace { namespace {
...@@ -80,7 +78,7 @@ namespace { ...@@ -80,7 +78,7 @@ namespace {
names.push_back("obj1"); names.push_back("obj1");
names.push_back("ob3"); names.push_back("ob3");
names.push_back("o2"); names.push_back("o2");
foreach(Expressions::SingleNamed_t expr, obj) { for(Expressions::SingleNamed_t expr : obj) {
std::string expected_name = names.back(); std::string expected_name = names.back();
EXPECT_EQ(expected_name, expr.first); EXPECT_EQ(expected_name, expr.first);
names.pop_back(); names.pop_back();
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "boost/algorithm/string.hpp" #include "boost/algorithm/string.hpp"
#include "boost/tuple/tuple.hpp" #include "boost/tuple/tuple.hpp"
#include "boost/foreach.hpp"
#include "Expression/SumErrSq.h" #include "Expression/SumErrSq.h"
#include "Expression/FromFile.h" #include "Expression/FromFile.h"
...@@ -12,8 +11,6 @@ ...@@ -12,8 +11,6 @@
#include "CommentAnnotatedInputFileParser.h" #include "CommentAnnotatedInputFileParser.h"
#include "Util/OptPilotException.h" #include "Util/OptPilotException.h"
#define foreach BOOST_FOREACH
typedef std::pair<std::string, DVar_t> namedDVar_t; typedef std::pair<std::string, DVar_t> namedDVar_t;
CommentAnnotatedInputFileParser::CommentAnnotatedInputFileParser( CommentAnnotatedInputFileParser::CommentAnnotatedInputFileParser(
...@@ -31,17 +28,17 @@ void CommentAnnotatedInputFileParser::getProblem(Expressions::Named_t &objective ...@@ -31,17 +28,17 @@ void CommentAnnotatedInputFileParser::getProblem(Expressions::Named_t &objective
Expressions::Named_t &constraints, Expressions::Named_t &constraints,
DVarContainer_t &dvars) { DVarContainer_t &dvars) {
foreach(Expressions::SingleNamed_t obj, nobjectives_) { for(Expressions::SingleNamed_t obj : nobjectives_) {
if(objectives_.count(obj.first) > 0) if(objectives_.count(obj.first) > 0)
objectives.insert(Expressions::SingleNamed_t(obj.first, obj.second)); objectives.insert(Expressions::SingleNamed_t(obj.first, obj.second));
} }
foreach(Expressions::SingleNamed_t constr, nconstraints_) { for(Expressions::SingleNamed_t constr : nconstraints_) {
if(constraints_.count(constr.first) > 0) if(constraints_.count(constr.first) > 0)
constraints.insert(Expressions::SingleNamed_t(constr.first, constr.second)); constraints.insert(Expressions::SingleNamed_t(constr.first, constr.second));
} }
foreach(namedDVar_t dvar, ndvars_) { for(namedDVar_t dvar : ndvars_) {
if(dvars_.count(dvar.first) > 0) if(dvars_.count(dvar.first) > 0)
dvars.insert(namedDVar_t(dvar.first, dvar.second)); dvars.insert(namedDVar_t(dvar.first, dvar.second));
} }
...@@ -137,7 +134,7 @@ std::set<std::string> CommentAnnotatedInputFileParser::getListAttribute( ...@@ -137,7 +134,7 @@ std::set<std::string> CommentAnnotatedInputFileParser::getListAttribute(
boost::token_compress_on); boost::token_compress_on);
std::set<std::string> ret; std::set<std::string> ret;
foreach(std::string list_attribute_name, attributes) { for(std::string list_attribute_name : attributes) {
boost::trim(list_attribute_name); boost::trim(list_attribute_name);
ret.insert(list_attribute_name); ret.insert(list_attribute_name);
} }
......
...@@ -5,9 +5,6 @@ ...@@ -5,9 +5,6 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
template<typename T> template<typename T>
class Statistics { class Statistics {
...@@ -42,8 +39,7 @@ public: ...@@ -42,8 +39,7 @@ public:
std::cout << "Statistics: " << stat_name_ << std::endl; std::cout << "Statistics: " << stat_name_ << std::endl;
T sum = 0; T sum = 0;
std::pair<std::string, T> stat; for(std::pair<std::string, T> stat : statistics_) {
foreach(stat, statistics_) {
sum += stat.second; sum += stat.second;
std::cout << "\t" << stat.first << " = " << stat.second << std::endl; std::cout << "\t" << stat.first << " = " << stat.second << std::endl;
} }
...@@ -56,8 +52,7 @@ public: ...@@ -56,8 +52,7 @@ public:
stream << "Statistics: " << stat_name_ << std::endl; stream << "Statistics: " << stat_name_ << std::endl;
T sum = 0; T sum = 0;
std::pair<std::string, T> stat; for (std::pair<std::string, T> stat : statistics_) {
foreach(stat, statistics_) {
sum += stat.second; sum += stat.second;
stream << "\t" << stat.first << " = " << stat.second << std::endl; stream << "\t" << stat.first << " = " << stat.second << std::endl;
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <map> #include <map>
#include "boost/smart_ptr.hpp" #include "boost/smart_ptr.hpp"
#include "boost/foreach.hpp"
#define foreach BOOST_FOREACH
#include "Util/Trace/TraceComponent.h" #include "Util/Trace/TraceComponent.h"
...@@ -35,7 +33,7 @@ public: ...@@ -35,7 +33,7 @@ public:
} }
void log(std::ostringstream &dump) { void log(std::ostringstream &dump) {
foreach(boost::shared_ptr<TraceComponent> component, pipeline_) { for(boost::shared_ptr<TraceComponent> component : pipeline_) {
component->execute(dump); component->execute(dump);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment