diff options
author | Andrej Rode <andrej.rode@ettus.com> | 2017-02-09 23:19:55 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-02-10 16:44:33 -0800 |
commit | 26cc20847cde543e759aa5cee9a27eaa69c5dd9e (patch) | |
tree | eee102333381e2313af59e725d6b7a06b665161f /host/include | |
parent | f3a004faf7d50cbb5564f5e2f67f54ee07e051dd (diff) | |
download | uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.gz uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.tar.bz2 uhd-26cc20847cde543e759aa5cee9a27eaa69c5dd9e.zip |
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.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/image_loader.hpp | 1 | ||||
-rw-r--r-- | host/include/uhd/property_tree.ipp | 5 | ||||
-rw-r--r-- | host/include/uhd/rfnoc/node_ctrl_base.ipp | 4 | ||||
-rw-r--r-- | host/include/uhd/types/dict.ipp | 17 | ||||
-rw-r--r-- | host/include/uhd/utils/assert_has.ipp | 3 | ||||
-rw-r--r-- | host/include/uhd/utils/soft_register.hpp | 23 |
6 files changed, 25 insertions, 28 deletions
diff --git a/host/include/uhd/image_loader.hpp b/host/include/uhd/image_loader.hpp index fd4a96781..4ebac288e 100644 --- a/host/include/uhd/image_loader.hpp +++ b/host/include/uhd/image_loader.hpp @@ -21,6 +21,7 @@ #include <string> #include <boost/function.hpp> +#include <boost/noncopyable.hpp> #include <uhd/config.hpp> #include <uhd/types/device_addr.hpp> diff --git a/host/include/uhd/property_tree.ipp b/host/include/uhd/property_tree.ipp index 6ed1056e6..ef63ced24 100644 --- a/host/include/uhd/property_tree.ipp +++ b/host/include/uhd/property_tree.ipp @@ -19,7 +19,6 @@ #define INCLUDED_UHD_PROPERTY_TREE_IPP #include <uhd/exception.hpp> -#include <boost/foreach.hpp> #include <boost/scoped_ptr.hpp> #include <vector> @@ -72,14 +71,14 @@ 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 } } 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/rfnoc/node_ctrl_base.ipp b/host/include/uhd/rfnoc/node_ctrl_base.ipp index d300f72a7..2492031be 100644 --- a/host/include/uhd/rfnoc/node_ctrl_base.ipp +++ b/host/include/uhd/rfnoc/node_ctrl_base.ipp @@ -45,7 +45,7 @@ namespace uhd { while (iters++ < MAX_ITER) { next_q.clear(); - BOOST_FOREACH(const sptr &this_node, search_q) { + for(const sptr &this_node: search_q) { // Add this node to the list of explored nodes explored.insert(this_node); // Create set of all child nodes of this_node that are not in explored: @@ -98,7 +98,7 @@ namespace uhd { std::vector< boost::shared_ptr<T> > descendant_rate_nodes = _find_child_node<T, downstream>(); value_type ret_val = NULL_VALUE; std::string first_node_id; - BOOST_FOREACH(const boost::shared_ptr<T> &node, descendant_rate_nodes) { + for(const boost::shared_ptr<T> &node: descendant_rate_nodes) { if (exclude_nodes.count(node)) { continue; } diff --git a/host/include/uhd/types/dict.ipp b/host/include/uhd/types/dict.ipp index 5fd4b536e..b9d367a3c 100644 --- a/host/include/uhd/types/dict.ipp +++ b/host/include/uhd/types/dict.ipp @@ -19,7 +19,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> @@ -61,7 +60,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; @@ -70,7 +69,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; @@ -78,7 +77,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; @@ -86,7 +85,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; @@ -94,7 +93,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); @@ -107,7 +106,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); @@ -115,7 +114,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())); @@ -138,7 +137,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") diff --git a/host/include/uhd/utils/assert_has.ipp b/host/include/uhd/utils/assert_has.ipp index 7b3c88cb7..6457cf2ee 100644 --- a/host/include/uhd/utils/assert_has.ipp +++ b/host/include/uhd/utils/assert_has.ipp @@ -21,7 +21,6 @@ #include <uhd/utils/algorithm.hpp> #include <uhd/exception.hpp> #include <boost/format.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> namespace uhd{ @@ -34,7 +33,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 2870ad595..d3a1e0943 100644 --- a/host/include/uhd/utils/soft_register.hpp +++ b/host/include/uhd/utils/soft_register.hpp @@ -27,7 +27,6 @@ #include <boost/thread/locks.hpp> #include <boost/unordered_map.hpp> #include <boost/tokenizer.hpp> -#include <boost/foreach.hpp> #include <boost/lexical_cast.hpp> #include <list> @@ -479,7 +478,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); } } @@ -491,7 +490,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(); } } @@ -503,7 +502,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(); } } @@ -527,7 +526,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; @@ -623,8 +622,8 @@ 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); @@ -633,7 +632,7 @@ public: (tokens.size() > 1 && _name == "")) { //If this is a top-level DB 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()); } @@ -642,11 +641,11 @@ public: } else if (not _regmap_dbs.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&) { @@ -663,11 +662,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()); } |