diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-09-28 11:50:22 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 12:21:32 -0800 |
commit | 0c43030e71f4786bf1ba1b7f08abf6b3d019761f (patch) | |
tree | 2abf254f18b327e9450d20379040aa1da1280a58 | |
parent | 1fe98e8701dd0b790b172762c3629db32956d1fc (diff) | |
download | uhd-0c43030e71f4786bf1ba1b7f08abf6b3d019761f.tar.gz uhd-0c43030e71f4786bf1ba1b7f08abf6b3d019761f.tar.bz2 uhd-0c43030e71f4786bf1ba1b7f08abf6b3d019761f.zip |
uhd: Replace BOOST_FOREACH(v, c) with for(v : c)
Also removes all references to boost/foreach.hpp. BOOST_FOREACH is no
longer necessary since all headers require C++11 anyway.
-rw-r--r-- | host/examples/test_dboard_coercion.cpp | 3 | ||||
-rw-r--r-- | host/examples/twinrx_freq_hopping.cpp | 2 | ||||
-rw-r--r-- | host/include/uhd/property_tree.ipp | 7 | ||||
-rw-r--r-- | host/include/uhd/types/dict.ipp | 22 | ||||
-rw-r--r-- | host/include/uhd/utils/assert_has.ipp | 3 | ||||
-rw-r--r-- | host/include/uhd/utils/soft_register.hpp | 21 | ||||
-rw-r--r-- | host/lib/transport/super_send_packet_handler.hpp | 2 |
7 files changed, 27 insertions, 33 deletions
diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index 8ea2446fa..0fb6f1872 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -22,7 +22,6 @@ static const double SAMP_RATE = 1e6; namespace po = boost::program_options; -typedef std::pair<double, double> double_pair; // BOOST_FOREACH doesn't like commas typedef std::vector<std::pair<double, double>> pair_vector; /************************************************************************ @@ -340,7 +339,7 @@ std::string coercion_test(uhd::usrp::multi_usrp::sptr usrp, } else { results += "USRP did not successfully set gain under the following circumstances:"; - for (double_pair bad_pair : bad_gain_vals) { + for (auto& bad_pair : bad_gain_vals) { double bad_freq = bad_pair.first; double bad_gain = bad_pair.second; results += str(boost::format("\nFrequency: %s, Gain: %5.2f") diff --git a/host/examples/twinrx_freq_hopping.cpp b/host/examples/twinrx_freq_hopping.cpp index d32a3e660..0dca1ee83 100644 --- a/host/examples/twinrx_freq_hopping.cpp +++ b/host/examples/twinrx_freq_hopping.cpp @@ -91,7 +91,7 @@ static void write_fft_to_file(const std::string& fft_path) { std::cout << "Calculating FFTs (this may take a while)... " << std::flush; std::ofstream ofile(fft_path.c_str(), std::ios::binary); - BOOST_FOREACH (const recv_buff_t& buff, buffs) { + for (const recv_buff_t& buff : buffs) { std::vector<float> fft = ascii_art_dft::log_pwr_dft(&buff.front(), buff.size()); ofile.write((char*)&fft[0], (sizeof(float) * fft.size())); } diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index 3bae2a451..73b3c737a 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -10,7 +10,6 @@ #define INCLUDED_UHD_PROPERTY_TREE_IPP #include <uhd/exception.hpp> -#include <boost/foreach.hpp> #include <typeindex> #include <vector> #include <memory> @@ -81,8 +80,7 @@ public: void _set_coerced(const T& value) { init_or_set_value(_coerced_value, value); - BOOST_FOREACH ( - typename property<T>::subscriber_type& csub, _coerced_subscribers) { + for (typename property<T>::subscriber_type& csub : _coerced_subscribers) { csub(get_value_ref(_coerced_value)); // let errors propagate } } @@ -90,8 +88,7 @@ public: property<T>& set(const T& value) { init_or_set_value(_value, value); - BOOST_FOREACH ( - typename property<T>::subscriber_type& dsub, _desired_subscribers) { + for (typename property<T>::subscriber_type& dsub : _desired_subscribers) { dsub(get_value_ref(_value)); // let errors propagate } if (not _coercer.empty()) { diff --git a/host/include/uhd/types/dict.ipp b/host/include/uhd/types/dict.ipp index 5a5024fcc..336a7dca9 100644 --- a/host/include/uhd/types/dict.ipp +++ b/host/include/uhd/types/dict.ipp @@ -1,6 +1,7 @@ // // Copyright 2010-2011 Ettus Research LLC // Copyright 2018 Ettus Research, a National Instruments Company +// Copyright 2019 Ettus Research, a National Instruments Brand // // SPDX-License-Identifier: GPL-3.0-or-later // @@ -9,7 +10,6 @@ #define INCLUDED_UHD_TYPES_DICT_IPP #include <uhd/exception.hpp> -#include <boost/foreach.hpp> #include <boost/format.hpp> #include <boost/lexical_cast.hpp> #include <typeinfo> @@ -51,7 +51,7 @@ namespace uhd{ template <typename Key, typename Val> std::vector<Key> dict<Key, Val>::keys(void) const{ std::vector<Key> keys; - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ keys.push_back(p.first); } return keys; @@ -60,7 +60,7 @@ namespace uhd{ template <typename Key, typename Val> std::vector<Val> dict<Key, Val>::vals(void) const{ std::vector<Val> vals; - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ vals.push_back(p.second); } return vals; @@ -68,7 +68,7 @@ namespace uhd{ template <typename Key, typename Val> bool dict<Key, Val>::has_key(const Key &key) const{ - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ if (p.first == key) return true; } return false; @@ -76,7 +76,7 @@ namespace uhd{ template <typename Key, typename Val> const Val &dict<Key, Val>::get(const Key &key, const Val &other) const{ - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ if (p.first == key) return p.second; } return other; @@ -84,7 +84,7 @@ namespace uhd{ template <typename Key, typename Val> const Val &dict<Key, Val>::get(const Key &key) const{ - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ if (p.first == key) return p.second; } throw key_not_found<Key, Val>(key); @@ -97,7 +97,7 @@ namespace uhd{ template <typename Key, typename Val> const Val &dict<Key, Val>::operator[](const Key &key) const{ - BOOST_FOREACH(const pair_t &p, _map){ + for(const pair_t &p : _map){ if (p.first == key) return p.second; } throw key_not_found<Key, Val>(key); @@ -105,7 +105,7 @@ namespace uhd{ template <typename Key, typename Val> Val &dict<Key, Val>::operator[](const Key &key){ - BOOST_FOREACH(pair_t &p, _map){ + for(pair_t &p : _map){ if (p.first == key) return p.second; } _map.push_back(std::make_pair(key, Val())); @@ -117,7 +117,7 @@ namespace uhd{ if (this->size() != other.size()){ return false; } - BOOST_FOREACH(const pair_t& p, _map) { + for(const pair_t& p : _map) { if (not (other.has_key(p.first) and other.get(p.first) == p.second)){ return false; } @@ -146,7 +146,7 @@ namespace uhd{ template <typename Key, typename Val> void dict<Key, Val>::update(const dict<Key, Val> &new_dict, bool fail_on_conflict) { - BOOST_FOREACH(const Key &key, new_dict.keys()) { + for(const Key &key : new_dict.keys()) { if (fail_on_conflict and has_key(key) and get(key) != new_dict[key]) { throw uhd::value_error(str( boost::format("Option merge conflict: %s:%s != %s:%s") @@ -161,7 +161,7 @@ namespace uhd{ dict<Key, Val>::operator std::map<Key, Val>() const { std::map<Key, Val> new_map; - BOOST_FOREACH (const pair_t& p, _map) { + for (const pair_t& p : _map) { new_map[p.first] = p.second; } return new_map; diff --git a/host/include/uhd/utils/assert_has.ipp b/host/include/uhd/utils/assert_has.ipp index 6237e127a..a60697f72 100644 --- a/host/include/uhd/utils/assert_has.ipp +++ b/host/include/uhd/utils/assert_has.ipp @@ -12,7 +12,6 @@ #include <uhd/exception.hpp> #include <boost/format.hpp> #include <boost/lexical_cast.hpp> -#include <boost/foreach.hpp> namespace uhd{ @@ -24,7 +23,7 @@ namespace uhd{ if (uhd::has(range, value)) return; std::string possible_values = ""; size_t i = 0; - BOOST_FOREACH(const T &v, range){ + for(const T &v : range){ if (i++ > 0) possible_values += ", "; possible_values += boost::lexical_cast<std::string>(v); } diff --git a/host/include/uhd/utils/soft_register.hpp b/host/include/uhd/utils/soft_register.hpp index ba716b206..ee80caab3 100644 --- a/host/include/uhd/utils/soft_register.hpp +++ b/host/include/uhd/utils/soft_register.hpp @@ -12,7 +12,6 @@ #include <uhd/types/wb_iface.hpp> #include <uhd/utils/dirty_tracked.hpp> #include <stdint.h> -#include <boost/foreach.hpp> #include <uhd/utils/noncopyable.hpp> #include <boost/thread/locks.hpp> #include <boost/thread/mutex.hpp> @@ -485,7 +484,7 @@ public: void initialize(wb_iface& iface, bool sync = false) { boost::lock_guard<boost::mutex> lock(_mutex); - BOOST_FOREACH (soft_register_base* reg, _reglist) { + for (soft_register_base* reg : _reglist) { reg->initialize(iface, sync); } } @@ -498,7 +497,7 @@ public: void flush() { boost::lock_guard<boost::mutex> lock(_mutex); - BOOST_FOREACH (soft_register_base* reg, _reglist) { + for (soft_register_base* reg : _reglist) { reg->flush(); } } @@ -511,7 +510,7 @@ public: void refresh() { boost::lock_guard<boost::mutex> lock(_mutex); - BOOST_FOREACH (soft_register_base* reg, _reglist) { + for (soft_register_base* reg : _reglist) { reg->refresh(); } } @@ -537,7 +536,7 @@ public: virtual std::vector<std::string> enumerate() const { std::vector<std::string> temp; - BOOST_FOREACH (const regmap_t::value_type& reg, _regmap) { + for (const regmap_t::value_type& reg : _regmap) { temp.push_back(_name + "/" + reg.first); } return temp; @@ -643,7 +642,7 @@ public: { // Turn the slash separated path string into tokens std::list<std::string> tokens; - BOOST_FOREACH (const std::string& node, + for (const std::string& node : boost::tokenizer<boost::char_separator<char> >( path, boost::char_separator<char>("/"))) { tokens.push_back(node); @@ -653,7 +652,7 @@ public: if (_name != "") tokens.pop_front(); if (tokens.size() == 2) { // 2 tokens => regmap/register path - BOOST_FOREACH (const soft_regmap_accessor_t* regmap, _regmaps) { + for (const soft_regmap_accessor_t* regmap : _regmaps) { if (regmap->get_name() == tokens.front()) { return regmap->lookup(tokens.back()); } @@ -663,11 +662,11 @@ public: .empty()) { //>2 tokens => <1 or more dbs>/regmap/register // Reconstruct path from tokens std::string newpath; - BOOST_FOREACH (const std::string& node, tokens) { + for (const std::string& node : tokens) { newpath += ("/" + node); } // Dispatch path to hierarchical DB - BOOST_FOREACH (const soft_regmap_accessor_t* db, _regmap_dbs) { + for (const soft_regmap_accessor_t* db : _regmap_dbs) { try { return db->lookup(newpath.substr(1)); } catch (std::exception&) { @@ -685,11 +684,11 @@ public: virtual std::vector<std::string> enumerate() const { std::vector<std::string> paths; - BOOST_FOREACH (const soft_regmap_accessor_t* regmap, _regmaps) { + for (const soft_regmap_accessor_t* regmap : _regmaps) { const std::vector<std::string>& regs = regmap->enumerate(); paths.insert(paths.end(), regs.begin(), regs.end()); } - BOOST_FOREACH (const soft_regmap_accessor_t* db, _regmap_dbs) { + for (const soft_regmap_accessor_t* db : _regmap_dbs) { const std::vector<std::string>& regs = db->enumerate(); paths.insert(paths.end(), regs.begin(), regs.end()); } diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp index cd707cb89..40ca2e414 100644 --- a/host/lib/transport/super_send_packet_handler.hpp +++ b/host/lib/transport/super_send_packet_handler.hpp @@ -315,7 +315,7 @@ private: if_packet_info.packet_count = _next_packet_seq; // get a buffer for each channel or timeout - BOOST_FOREACH (xport_chan_props_type& props, _props) { + for (xport_chan_props_type& props : _props) { if (not props.buff) props.buff = props.get_buff(timeout); if (not props.buff) |