From 26cc20847cde543e759aa5cee9a27eaa69c5dd9e Mon Sep 17 00:00:00 2001 From: Andrej Rode Date: Thu, 9 Feb 2017 23:19:55 -0800 Subject: uhd: replace BOOST_FOREACH with C++11 range-based for loop Note: This is the first commit that uses for-range, and range-based for-loops are now usable for UHD development. --- host/lib/usrp/common/ad936x_manager.cpp | 9 ++++----- host/lib/usrp/common/apply_corrections.cpp | 3 +-- host/lib/usrp/common/constrained_device_args.hpp | 2 +- host/lib/usrp/common/max287x.hpp | 2 +- host/lib/usrp/common/usrp3_fw_ctrl_iface.cpp | 1 - host/lib/usrp/common/validate_subdev_spec.cpp | 9 ++++----- 6 files changed, 11 insertions(+), 15 deletions(-) (limited to 'host/lib/usrp/common') diff --git a/host/lib/usrp/common/ad936x_manager.cpp b/host/lib/usrp/common/ad936x_manager.cpp index 2b6d69c15..20e06a072 100644 --- a/host/lib/usrp/common/ad936x_manager.cpp +++ b/host/lib/usrp/common/ad936x_manager.cpp @@ -17,7 +17,6 @@ #include "ad936x_manager.hpp" #include -#include #include #include @@ -66,7 +65,7 @@ class ad936x_manager_impl : public ad936x_manager ***********************************************************************/ void init_codec() { - BOOST_FOREACH(const std::string &rx_fe, _rx_frontends) { + for(const std::string &rx_fe: _rx_frontends) { _codec_ctrl->set_gain(rx_fe, DEFAULT_GAIN); _codec_ctrl->set_bw_filter(rx_fe, DEFAULT_BANDWIDTH); _codec_ctrl->tune(rx_fe, DEFAULT_FREQ); @@ -74,7 +73,7 @@ class ad936x_manager_impl : public ad936x_manager _codec_ctrl->set_iq_balance_auto(rx_fe, DEFAULT_AUTO_IQ_BALANCE); _codec_ctrl->set_agc(rx_fe, DEFAULT_AGC_ENABLE); } - BOOST_FOREACH(const std::string &tx_fe, _tx_frontends) { + for(const std::string &tx_fe: _tx_frontends) { _codec_ctrl->set_gain(tx_fe, DEFAULT_GAIN); _codec_ctrl->set_bw_filter(tx_fe, DEFAULT_BANDWIDTH); _codec_ctrl->tune(tx_fe, DEFAULT_FREQ); @@ -218,7 +217,7 @@ class ad936x_manager_impl : public ad936x_manager } // Gains - BOOST_FOREACH(const std::string &name, ad9361_ctrl::get_gain_names(key)) + for(const std::string &name: ad9361_ctrl::get_gain_names(key)) { subtree->create(uhd::fs_path("gains") / name / "range") .set(ad9361_ctrl::get_gain_range(key)); @@ -278,7 +277,7 @@ class ad936x_manager_impl : public ad936x_manager } // Frontend filters - BOOST_FOREACH(const std::string &filter_name, _codec_ctrl->get_filter_names(key)) { + for(const std::string &filter_name: _codec_ctrl->get_filter_names(key)) { subtree->create(uhd::fs_path("filters") / filter_name / "value" ) .set_publisher(boost::bind(&ad9361_ctrl::get_filter, _codec_ctrl, key, filter_name)) .add_coerced_subscriber(boost::bind(&ad9361_ctrl::set_filter, _codec_ctrl, key, filter_name, _1)); diff --git a/host/lib/usrp/common/apply_corrections.cpp b/host/lib/usrp/common/apply_corrections.cpp index 272e0e093..f1ba47bd9 100644 --- a/host/lib/usrp/common/apply_corrections.cpp +++ b/host/lib/usrp/common/apply_corrections.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -114,7 +113,7 @@ static void apply_fe_corrections( bool read_data = false, skip_next = false;; std::vector datas; - BOOST_FOREACH(const uhd::csv::row_type &row, rows){ + for(const uhd::csv::row_type &row: rows){ if (not read_data and not row.empty() and row[0] == "DATA STARTS HERE"){ read_data = true; skip_next = true; diff --git a/host/lib/usrp/common/constrained_device_args.hpp b/host/lib/usrp/common/constrained_device_args.hpp index 1bfd1df00..47c5f4cc0 100644 --- a/host/lib/usrp/common/constrained_device_args.hpp +++ b/host/lib/usrp/common/constrained_device_args.hpp @@ -260,7 +260,7 @@ namespace usrp { template static inline void _enforce_discrete(const arg_t& arg, const std::vector& valid_values) { bool match = false; - BOOST_FOREACH(const data_t& val, valid_values) { + for(const data_t& val: valid_values) { if (val == arg.get()) { match = true; break; diff --git a/host/lib/usrp/common/max287x.hpp b/host/lib/usrp/common/max287x.hpp index 9022e0f02..df6f6bc26 100644 --- a/host/lib/usrp/common/max287x.hpp +++ b/host/lib/usrp/common/max287x.hpp @@ -402,7 +402,7 @@ public: while (vco_freq < MIN_VCO_FREQ) vco_freq *=2; uint8_t vco_index = 0xFF; - BOOST_FOREACH(const vco_map_t::value_type &vco, max2871_vco_map) + for(const vco_map_t::value_type &vco: max2871_vco_map) { if (uhd::math::fp_compare::fp_compare_epsilon(vco_freq) < vco.second.stop()) { diff --git a/host/lib/usrp/common/usrp3_fw_ctrl_iface.cpp b/host/lib/usrp/common/usrp3_fw_ctrl_iface.cpp index 16ee84140..35758d4dd 100644 --- a/host/lib/usrp/common/usrp3_fw_ctrl_iface.cpp +++ b/host/lib/usrp/common/usrp3_fw_ctrl_iface.cpp @@ -22,7 +22,6 @@ #include #include #include //used for htonl and ntohl -#include #include "fw_comm_protocol.h" namespace uhd { namespace usrp { namespace usrp3 { diff --git a/host/lib/usrp/common/validate_subdev_spec.cpp b/host/lib/usrp/common/validate_subdev_spec.cpp index fab40b204..76e61221e 100644 --- a/host/lib/usrp/common/validate_subdev_spec.cpp +++ b/host/lib/usrp/common/validate_subdev_spec.cpp @@ -18,7 +18,6 @@ #include "validate_subdev_spec.hpp" #include #include -#include #include using namespace uhd; @@ -52,19 +51,19 @@ void uhd::usrp::validate_subdev_spec( //make a list of all possible specs subdev_spec_t all_specs; - BOOST_FOREACH(const std::string &db, tree->list(str(boost::format("/mboards/%s/dboards") % mb))){ - BOOST_FOREACH(const std::string &sd, tree->list(str(boost::format("/mboards/%s/dboards/%s/%s_frontends") % mb % db % type))){ + for(const std::string &db: tree->list(str(boost::format("/mboards/%s/dboards") % mb))){ + for(const std::string &sd: tree->list(str(boost::format("/mboards/%s/dboards/%s/%s_frontends") % mb % db % type))){ all_specs.push_back(subdev_spec_pair_t(db, sd)); } } //validate that the spec is possible - BOOST_FOREACH(const subdev_spec_pair_t &pair, spec){ + for(const subdev_spec_pair_t &pair: spec){ uhd::assert_has(all_specs, pair, str(boost::format("%s subdevice specification on mboard %s") % type % mb)); } //enable selected frontends, disable others - BOOST_FOREACH(const subdev_spec_pair_t &pair, all_specs){ + for(const subdev_spec_pair_t &pair: all_specs){ const bool enb = uhd::has(spec, pair); tree->access(str(boost::format( "/mboards/%s/dboards/%s/%s_frontends/%s/enabled" -- cgit v1.2.3