From 47cdd6319c74a7b823843aad5ff3fa370ed1e6ef Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@ettus.com>
Date: Tue, 27 Jun 2017 19:06:50 -0700
Subject: uhd: Replaced many lexical_cast with appropriate C++11 equivalents

---
 host/lib/property_tree.cpp                               |  2 +-
 host/lib/rfnoc/block_ctrl_base.cpp                       | 12 ++++++------
 host/lib/rfnoc/blockdef_xml_impl.cpp                     |  2 +-
 host/lib/rfnoc/nocscript/expression.cpp                  | 16 ++++++++--------
 host/lib/rfnoc/nocscript/expression.hpp                  |  3 +--
 host/lib/transport/nirio/niusrprio_session.cpp           |  1 -
 host/lib/transport/xport_benchmarker.cpp                 |  6 +++---
 host/lib/types/sensors.cpp                               |  5 ++---
 host/lib/types/sensors_c.cpp                             |  5 +----
 host/lib/usrp/b100/b100_impl.cpp                         |  1 -
 host/lib/usrp/common/constrained_device_args.hpp         |  9 ++++-----
 host/lib/usrp/dboard_eeprom.cpp                          |  2 +-
 host/lib/usrp/dboard_eeprom_c.cpp                        |  6 ++----
 host/lib/usrp/e300/e300_eeprom_manager.cpp               |  6 +++---
 host/lib/usrp/e300/e300_sensor_manager.cpp               |  6 +++---
 host/lib/usrp/e300/e300_sysfs_hooks.cpp                  |  6 +++---
 host/lib/usrp/gpsd_iface.cpp                             |  1 -
 host/lib/usrp/mboard_eeprom.cpp                          | 16 ++++++++--------
 host/lib/usrp/multi_usrp.cpp                             |  6 +++---
 host/lib/usrp/n230/n230_eeprom_manager.cpp               |  6 +++---
 host/lib/usrp/n230/n230_resource_manager.cpp             |  4 +---
 host/lib/usrp/n230/n230_stream_manager.cpp               | 16 ++++++++--------
 host/lib/usrp/usrp1/usrp1_impl.cpp                       |  4 ++--
 host/lib/usrp/usrp2/clock_ctrl.cpp                       |  1 -
 host/lib/usrp/usrp2/usrp2_impl.cpp                       |  9 ++++-----
 host/lib/usrp/x300/x300_fw_ctrl.cpp                      |  3 +--
 host/lib/usrp/x300/x300_impl.cpp                         |  6 +++---
 host/lib/usrp/x300/x300_io_impl.cpp                      |  4 ++--
 host/lib/usrp/x300/x300_radio_ctrl_impl.hpp              |  2 +-
 host/lib/usrp_clock/octoclock/octoclock_eeprom.cpp       |  3 +--
 host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp |  1 -
 host/lib/usrp_clock/octoclock/octoclock_impl.cpp         |  4 ++--
 32 files changed, 78 insertions(+), 96 deletions(-)

(limited to 'host/lib')

diff --git a/host/lib/property_tree.cpp b/host/lib/property_tree.cpp
index d62f61878..b5ad10b21 100644
--- a/host/lib/property_tree.cpp
+++ b/host/lib/property_tree.cpp
@@ -66,7 +66,7 @@ fs_path uhd::operator/(const fs_path &lhs, const fs_path &rhs){
 
 fs_path uhd::operator/(const fs_path &lhs, size_t rhs)
 {
-    fs_path rhs_str = boost::lexical_cast<std::string>(rhs);
+    fs_path rhs_str = std::to_string(rhs);
     return lhs / rhs_str;
 }
 
diff --git a/host/lib/rfnoc/block_ctrl_base.cpp b/host/lib/rfnoc/block_ctrl_base.cpp
index e9d6c0030..1a753403a 100644
--- a/host/lib/rfnoc/block_ctrl_base.cpp
+++ b/host/lib/rfnoc/block_ctrl_base.cpp
@@ -195,8 +195,8 @@ void block_ctrl_base::_init_block_args()
         fs_path arg_val_path = arg_path / arg["port"] / arg["name"] / "value";
         if (not arg["value"].empty()) {
             if (arg["type"] == "int_vector") { throw uhd::runtime_error("not yet implemented: int_vector"); }
-            else if (arg["type"] == "int") { _tree->access<int>(arg_val_path).set(boost::lexical_cast<int>(arg["value"])); }
-            else if (arg["type"] == "double") { _tree->access<double>(arg_val_path).set(boost::lexical_cast<double>(arg["value"])); }
+            else if (arg["type"] == "int") { _tree->access<int>(arg_val_path).set(std::stoi(arg["value"])); }
+            else if (arg["type"] == "double") { _tree->access<double>(arg_val_path).set(std::stod(arg["value"])); }
             else if (arg["type"] == "string") { _tree->access<string>(arg_val_path).set(arg["value"]); }
             else { UHD_THROW_INVALID_CODE_PATH(); }
         }
@@ -453,10 +453,10 @@ void block_ctrl_base::set_arg(const std::string &key, const std::string &val, co
             _tree->access<std::string>(arg_val_path).set(val);
         }
         else if (type == "int") {
-            _tree->access<int>(arg_val_path).set(boost::lexical_cast<int>(val));
+            _tree->access<int>(arg_val_path).set(std::stoi(val));
         }
         else if (type == "double") {
-            _tree->access<double>(arg_val_path).set(boost::lexical_cast<double>(val));
+            _tree->access<double>(arg_val_path).set(std::stod(val));
         }
         else if (type == "int_vector") {
             throw uhd::runtime_error("not yet implemented: int_vector");
@@ -494,10 +494,10 @@ std::string block_ctrl_base::get_arg(const std::string &key, const size_t port)
         return _tree->access<std::string>(arg_val_path).get();
     }
     else if (type == "int") {
-        return boost::lexical_cast<std::string>(_tree->access<int>(arg_val_path).get());
+        return std::to_string(_tree->access<int>(arg_val_path).get());
     }
     else if (type == "double") {
-        return boost::lexical_cast<std::string>(_tree->access<double>(arg_val_path).get());
+        return std::to_string(_tree->access<double>(arg_val_path).get());
     }
     else if (type == "int_vector") {
         throw uhd::runtime_error("not yet implemented: int_vector");
diff --git a/host/lib/rfnoc/blockdef_xml_impl.cpp b/host/lib/rfnoc/blockdef_xml_impl.cpp
index 5f8af232d..cf975b3c2 100644
--- a/host/lib/rfnoc/blockdef_xml_impl.cpp
+++ b/host/lib/rfnoc/blockdef_xml_impl.cpp
@@ -310,7 +310,7 @@ public:
             }
             // We have to be extra-careful with the port numbers:
             if (port["port"].empty()) {
-                port["port"] = boost::lexical_cast<std::string>(n_ports);
+                port["port"] = std::to_string(n_ports);
             }
             size_t new_port_number;
             try {
diff --git a/host/lib/rfnoc/nocscript/expression.cpp b/host/lib/rfnoc/nocscript/expression.cpp
index 257e0b447..4f7d98108 100644
--- a/host/lib/rfnoc/nocscript/expression.cpp
+++ b/host/lib/rfnoc/nocscript/expression.cpp
@@ -54,12 +54,12 @@ expression_literal::expression_literal(
         if (_val.substr(0, 2) == "0x") {
             _int_val = uhd::cast::hexstr_cast<int>(_val);
         } else {
-            _int_val = boost::lexical_cast<int>(_val);
+            _int_val = std::stoi(_val);
         }
         break;
 
     case expression::TYPE_DOUBLE:
-        _double_val = boost::lexical_cast<double>(_val);
+        _double_val = std::stod(_val);
         break;
 
     case expression::TYPE_BOOL:
@@ -67,7 +67,7 @@ expression_literal::expression_literal(
             _bool_val = true;
         } else {
             // lexical cast to bool is too picky
-            _bool_val = bool(boost::lexical_cast<int>(_val));
+            _bool_val = bool(std::stoi(_val));
         }
         break;
 
@@ -77,7 +77,7 @@ expression_literal::expression_literal(
         std::vector<std::string> subtoken_list;
         boost::split(subtoken_list, str_vec, boost::is_any_of(", "), boost::token_compress_on);
         for(const std::string &t:  subtoken_list) {
-            _int_vector_val.push_back(boost::lexical_cast<int>(t));
+            _int_vector_val.push_back(std::stoi(t));
         }
         break;
         }
@@ -142,11 +142,11 @@ bool expression_literal::to_bool() const
 {
     switch (_type) {
         case TYPE_INT:
-            return bool(boost::lexical_cast<int>(_val));
+            return bool(std::stoi(_val));
         case TYPE_STRING:
             return not _val.empty();
         case TYPE_DOUBLE:
-            return bool(boost::lexical_cast<double>(_val));
+            return bool(std::stod(_val));
         case TYPE_BOOL:
             return _bool_val;
         case TYPE_INT_VECTOR:
@@ -205,11 +205,11 @@ std::string expression_literal::repr() const
 {
     switch (_type) {
         case TYPE_INT:
-            return boost::lexical_cast<std::string>(_int_val);
+            return std::to_string(_int_val);
         case TYPE_STRING:
             return _val;
         case TYPE_DOUBLE:
-            return boost::lexical_cast<std::string>(_double_val);
+            return std::to_string(_double_val);
         case TYPE_BOOL:
             return _bool_val ? "TRUE" : "FALSE";
         case TYPE_INT_VECTOR:
diff --git a/host/lib/rfnoc/nocscript/expression.hpp b/host/lib/rfnoc/nocscript/expression.hpp
index 1acd02009..6cf649a59 100644
--- a/host/lib/rfnoc/nocscript/expression.hpp
+++ b/host/lib/rfnoc/nocscript/expression.hpp
@@ -17,7 +17,6 @@
 
 #include <uhd/exception.hpp>
 #include <boost/shared_ptr.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/function.hpp>
 #include <boost/make_shared.hpp>
 #include <vector>
@@ -300,7 +299,7 @@ class expression_function : public expression_container
             const std::string &name,
             const boost::shared_ptr<function_table> func_table
     );
-    ~expression_function(){};
+    ~expression_function(){}
 
     //! Add an argument expression
     virtual void add(expression::sptr new_expr);
diff --git a/host/lib/transport/nirio/niusrprio_session.cpp b/host/lib/transport/nirio/niusrprio_session.cpp
index 07ec6a266..f1e31572c 100644
--- a/host/lib/transport/nirio/niusrprio_session.cpp
+++ b/host/lib/transport/nirio/niusrprio_session.cpp
@@ -21,7 +21,6 @@
 #include <uhd/transport/nirio/status.h>
 #include <boost/format.hpp>
 #include <boost/algorithm/string.hpp>
-#include <boost/lexical_cast.hpp>
 #include <stdio.h>
 #include <fstream>
 //@TODO: Move the register defs required by the class to a common location
diff --git a/host/lib/transport/xport_benchmarker.cpp b/host/lib/transport/xport_benchmarker.cpp
index d8f533edc..7157c1ae9 100644
--- a/host/lib/transport/xport_benchmarker.cpp
+++ b/host/lib/transport/xport_benchmarker.cpp
@@ -54,9 +54,9 @@ const device_addr_t& xport_benchmarker::benchmark_throughput_chdr
     _results["RX-Bytes"] = (boost::format("%.2fMB") % (rx_bytes/(1024*1024))).str();
     _results["TX-Throughput"] = (boost::format("%.2fMB/s") % (tx_rate/(1024*1024))).str();
     _results["RX-Throughput"] = (boost::format("%.2fMB/s") % (rx_rate/(1024*1024))).str();
-    _results["TX-Timeouts"] = boost::lexical_cast<std::string>(_num_tx_timeouts);
-    _results["RX-Timeouts"] = boost::lexical_cast<std::string>(_num_rx_timeouts);
-    _results["Data-Errors"] = boost::lexical_cast<std::string>(_num_data_errors);
+    _results["TX-Timeouts"] = std::to_string(_num_tx_timeouts);
+    _results["RX-Timeouts"] = std::to_string(_num_rx_timeouts);
+    _results["Data-Errors"] = std::to_string(_num_data_errors);
 
     return _results;
 }
diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp
index 0406e35d4..5ac48dc4b 100644
--- a/host/lib/types/sensors.cpp
+++ b/host/lib/types/sensors.cpp
@@ -17,7 +17,6 @@
 
 #include <uhd/types/sensors.hpp>
 #include <uhd/exception.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/format.hpp>
 
 using namespace uhd;
@@ -92,11 +91,11 @@ bool sensor_value_t::to_bool(void) const{
 }
 
 signed sensor_value_t::to_int(void) const{
-    return boost::lexical_cast<signed>(value);
+    return std::stoi(value);
 }
 
 double sensor_value_t::to_real(void) const{
-    return boost::lexical_cast<double>(value);
+    return std::stod(value);
 }
 
 sensor_value_t& sensor_value_t::operator=(const sensor_value_t& rhs)
diff --git a/host/lib/types/sensors_c.cpp b/host/lib/types/sensors_c.cpp
index f1976c102..cec4fbaff 100644
--- a/host/lib/types/sensors_c.cpp
+++ b/host/lib/types/sensors_c.cpp
@@ -16,12 +16,9 @@
 //
 
 #include <uhd/types/sensors.h>
-
-#include <boost/lexical_cast.hpp>
-
 #include <stdexcept>
-#include <string.h>
 #include <string>
+#include <string.h>
 
 uhd_error uhd_sensor_value_make_from_bool(
     uhd_sensor_value_handle* h,
diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp
index 25f99e85e..27af43c48 100644
--- a/host/lib/usrp/b100/b100_impl.cpp
+++ b/host/lib/usrp/b100/b100_impl.cpp
@@ -29,7 +29,6 @@
 #include <boost/assign/list_of.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/thread/thread.hpp>
-#include <boost/lexical_cast.hpp>
 #include <cstdio>
 #include <iostream>
 
diff --git a/host/lib/usrp/common/constrained_device_args.hpp b/host/lib/usrp/common/constrained_device_args.hpp
index 47c5f4cc0..42632d0dd 100644
--- a/host/lib/usrp/common/constrained_device_args.hpp
+++ b/host/lib/usrp/common/constrained_device_args.hpp
@@ -20,7 +20,6 @@
 
 #include <uhd/types/device_addr.hpp>
 #include <uhd/exception.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/format.hpp>
 #include <boost/algorithm/string.hpp>
 #include <boost/assign/list_of.hpp>
@@ -116,7 +115,7 @@ namespace usrp {
                 }
             }
             inline virtual std::string to_string() const {
-                return key() + "=" + boost::lexical_cast<std::string>(get());
+                return key() + "=" + std::to_string(get());
             }
         private:
             data_t _value;
@@ -192,7 +191,7 @@ namespace usrp {
             }
             inline void parse(const std::string& str_rep) {
                 try {
-                    _value = (boost::lexical_cast<int>(str_rep) != 0);
+                    _value = (std::stoi(str_rep) != 0);
                 } catch (std::exception& ex) {
                     if (str_rep.empty()) {
                         //If str_rep is empty then the device_addr was set
@@ -250,7 +249,7 @@ namespace usrp {
                 throw uhd::value_error(str(boost::format(
                     "Invalid device arg value: %s (Minimum: %s, Maximum: %s)") %
                     arg.to_string() %
-                    boost::lexical_cast<std::string>(min) % boost::lexical_cast<std::string>(max)));
+                    std::to_string(min) % std::to_string(max)));
             }
         }
 
@@ -269,7 +268,7 @@ namespace usrp {
             if (!match) {
                 std::string valid_values_str;
                 for (size_t i = 0; i < valid_values.size(); i++) {
-                    valid_values_str += ((i==0)?"":", ") + boost::lexical_cast<std::string>(valid_values[i]);
+                    valid_values_str += ((i==0)?"":", ") + std::to_string(valid_values[i]);
                     throw uhd::value_error(str(boost::format(
                         "Invalid device arg value: %s (Valid: {%s})") %
                         arg.to_string() % valid_values_str
diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp
index 900d28e80..bff9f7a15 100644
--- a/host/lib/usrp/dboard_eeprom.cpp
+++ b/host/lib/usrp/dboard_eeprom.cpp
@@ -107,7 +107,7 @@ void dboard_eeprom_t::load(i2c_iface &iface, uint8_t addr){
             | (uint16_t(bytes[DB_EEPROM_REV_MSB]) << 8)
         ;
         if (rev_num != 0 and rev_num != 0xffff){
-            revision = boost::lexical_cast<std::string>(rev_num);
+            revision = std::to_string(rev_num);
         }
 
     }catch(const uhd::assertion_error &){
diff --git a/host/lib/usrp/dboard_eeprom_c.cpp b/host/lib/usrp/dboard_eeprom_c.cpp
index e3ef4933f..5d617f941 100644
--- a/host/lib/usrp/dboard_eeprom_c.cpp
+++ b/host/lib/usrp/dboard_eeprom_c.cpp
@@ -18,8 +18,6 @@
 #include <uhd/usrp/dboard_eeprom.h>
 #include <uhd/error.h>
 
-#include <boost/lexical_cast.hpp>
-
 #include <string.h>
 
 uhd_error uhd_dboard_eeprom_make(
@@ -84,7 +82,7 @@ uhd_error uhd_dboard_eeprom_get_revision(
     int* revision_out
 ){
     UHD_SAFE_C_SAVE_ERROR(h,
-        *revision_out = boost::lexical_cast<int>(h->dboard_eeprom_cpp.revision);
+        *revision_out = std::stoi(h->dboard_eeprom_cpp.revision);
     )
 }
 
@@ -93,7 +91,7 @@ uhd_error uhd_dboard_eeprom_set_revision(
     int revision
 ){
     UHD_SAFE_C_SAVE_ERROR(h,
-        h->dboard_eeprom_cpp.revision = boost::lexical_cast<std::string>(revision);
+        h->dboard_eeprom_cpp.revision = std::to_string(revision);
     )
 }
 
diff --git a/host/lib/usrp/e300/e300_eeprom_manager.cpp b/host/lib/usrp/e300/e300_eeprom_manager.cpp
index d43ca3d4c..f994ec996 100644
--- a/host/lib/usrp/e300/e300_eeprom_manager.cpp
+++ b/host/lib/usrp/e300/e300_eeprom_manager.cpp
@@ -67,9 +67,9 @@ const mboard_eeprom_t& e300_eeprom_manager::read_mb_eeprom(void)
 
     mb_eeprom_map_t &map = *map_ptr;
 
-    _mb_eeprom["product"] = boost::lexical_cast<std::string>(
+    _mb_eeprom["product"] = std::to_string(
         uhd::ntohx<uint16_t>(map.hw_product));
-    _mb_eeprom["revision"] = boost::lexical_cast<std::string>(
+    _mb_eeprom["revision"] = std::to_string(
         uhd::ntohx<uint16_t>(map.hw_revision));
     _mb_eeprom["serial"] = _bytes_to_string(
         map.serial, MB_SERIAL_LEN);
@@ -101,7 +101,7 @@ const dboard_eeprom_t& e300_eeprom_manager::read_db_eeprom(void)
     _db_eeprom.id = uhd::usrp::dboard_id_t::from_uint16(
         uhd::ntohx<uint16_t>(map.hw_product));
 
-    _db_eeprom.revision = boost::lexical_cast<std::string>(
+    _db_eeprom.revision = std::to_string(
         uhd::ntohx<uint16_t>(map.hw_revision));
     _db_eeprom.serial = _bytes_to_string(
         map.serial, DB_SERIAL_LEN);
diff --git a/host/lib/usrp/e300/e300_sensor_manager.cpp b/host/lib/usrp/e300/e300_sensor_manager.cpp
index b96656e5e..52f888799 100644
--- a/host/lib/usrp/e300/e300_sensor_manager.cpp
+++ b/host/lib/usrp/e300/e300_sensor_manager.cpp
@@ -171,11 +171,11 @@ public:
 
     uhd::sensor_value_t get_mb_temp(void)
     {
-        double scale = boost::lexical_cast<double>(
+        double scale = std::stod(
             e300_get_sysfs_attr(E300_TEMP_SYSFS, "in_temp0_scale"));
-        unsigned long raw = boost::lexical_cast<unsigned long>(
+        unsigned long raw = std::stoul(
             e300_get_sysfs_attr(E300_TEMP_SYSFS, "in_temp0_raw"));
-        unsigned long offset = boost::lexical_cast<unsigned long>(
+        unsigned long offset = std::stoul(
             e300_get_sysfs_attr(E300_TEMP_SYSFS, "in_temp0_offset"));
         return sensor_value_t("temp", (raw + offset) * scale / 1000, "C");
     }
diff --git a/host/lib/usrp/e300/e300_sysfs_hooks.cpp b/host/lib/usrp/e300/e300_sysfs_hooks.cpp
index bcfca8b92..08562f7d7 100644
--- a/host/lib/usrp/e300/e300_sysfs_hooks.cpp
+++ b/host/lib/usrp/e300/e300_sysfs_hooks.cpp
@@ -96,11 +96,11 @@ e300_fifo_config_t e300_read_sysfs(void)
 
     e300_fifo_config_t config;
 
-    config.buff_length  = boost::lexical_cast<unsigned long>(
+    config.buff_length  = std::stoul(
         e300_get_sysfs_attr(E300_AXI_FPGA_SYSFS, "buffer_length"));
-    config.ctrl_length = boost::lexical_cast<unsigned long>(
+    config.ctrl_length = std::stoul(
         e300_get_sysfs_attr(E300_AXI_FPGA_SYSFS, "control_length"));
-    config.phys_addr = boost::lexical_cast<unsigned long>(
+    config.phys_addr = std::stoul(
         e300_get_sysfs_attr(E300_AXI_FPGA_SYSFS, "phys_addr"));
 
     return config;
diff --git a/host/lib/usrp/gpsd_iface.cpp b/host/lib/usrp/gpsd_iface.cpp
index c5d4a1745..1955a4121 100644
--- a/host/lib/usrp/gpsd_iface.cpp
+++ b/host/lib/usrp/gpsd_iface.cpp
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include "boost/date_time/gregorian/gregorian.hpp"
 #include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/thread/shared_mutex.hpp>
 #include <boost/thread.hpp>
 #include <boost/math/special_functions/fpclassify.hpp>
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index ecae5e56d..f7222426d 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -50,7 +50,7 @@ static byte_vector_t string_to_uint16_bytes(const std::string &num_str){
 //! convert a byte vector read from eeprom to a string
 static std::string uint16_bytes_to_string(const byte_vector_t &bytes){
     const uint16_t num = (uint16_t(bytes.at(0)) << 0) | (uint16_t(bytes.at(1)) << 8);
-    return (num == 0 or num == 0xffff)? "" : boost::lexical_cast<std::string>(num);
+    return (num == 0 or num == 0xffff)? "" : std::to_string(num);
 }
 
 /***********************************************************************
@@ -134,7 +134,7 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
     if (mb_eeprom["serial"].empty()){
         byte_vector_t mac_addr_bytes = mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes();
         unsigned serial = mac_addr_bytes.at(5) | (unsigned(mac_addr_bytes.at(4) & 0x0f) << 8);
-        mb_eeprom["serial"] = boost::lexical_cast<std::string>(serial);
+        mb_eeprom["serial"] = std::to_string(serial);
     }
 }
 
@@ -417,7 +417,7 @@ static void load_b000(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
     );
     master_clock_rate = ntohl(master_clock_rate);
     if (master_clock_rate > 1e6 and master_clock_rate < 1e9){
-        mb_eeprom["mcr"] = boost::lexical_cast<std::string>(master_clock_rate);
+        mb_eeprom["mcr"] = std::to_string(master_clock_rate);
     }
     else mb_eeprom["mcr"] = "";
 }
@@ -437,7 +437,7 @@ static void store_b000(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
 
     //store the master clock rate as a 32-bit uint in Hz
     if (mb_eeprom.has_key("mcr")){
-        uint32_t master_clock_rate = uint32_t(boost::lexical_cast<double>(mb_eeprom["mcr"]));
+        uint32_t master_clock_rate = uint32_t(std::stod(mb_eeprom["mcr"]));
         master_clock_rate = htonl(master_clock_rate);
         const byte_vector_t rate_bytes(
             reinterpret_cast<const uint8_t *>(&master_clock_rate),
@@ -606,10 +606,10 @@ static void load_e100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
     byte_vector_t map_bytes = iface.read_eeprom(E100_EEPROM_ADDR, 0, num_bytes);
     e100_eeprom_map map; std::memcpy(&map, &map_bytes[0], map_bytes.size());
 
-    mb_eeprom["vendor"] = boost::lexical_cast<std::string>(uhd::ntohx(map.vendor));
-    mb_eeprom["device"] = boost::lexical_cast<std::string>(uhd::ntohx(map.device));
-    mb_eeprom["revision"] = boost::lexical_cast<std::string>(unsigned(map.revision));
-    mb_eeprom["content"] = boost::lexical_cast<std::string>(unsigned(map.content));
+    mb_eeprom["vendor"] = std::to_string(uhd::ntohx(map.vendor));
+    mb_eeprom["device"] = std::to_string(uhd::ntohx(map.device));
+    mb_eeprom["revision"] = std::to_string(unsigned(map.revision));
+    mb_eeprom["content"] = std::to_string(unsigned(map.content));
 
     #define load_e100_string_xx(key) mb_eeprom[#key] = bytes_to_string(iface.read_eeprom( \
         E100_EEPROM_ADDR, offsetof(e100_eeprom_map, key), sizeof_member(e100_eeprom_map, key) \
diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp
index 0910ad59d..3dcfe3bd9 100644
--- a/host/lib/usrp/multi_usrp.cpp
+++ b/host/lib/usrp/multi_usrp.cpp
@@ -1763,7 +1763,7 @@ private:
     {
         try
         {
-            const std::string tree_path = "/mboards/" + boost::lexical_cast<std::string>(mboard);
+            const std::string tree_path = "/mboards/" + std::to_string(mboard);
             if (_tree->exists(tree_path)) {
                 return tree_path;
             } else {
@@ -1791,7 +1791,7 @@ private:
 
         try
         {
-            const std::string tree_path = mb_root(mcp.mboard) / "rx_dsps" / boost::lexical_cast<std::string>(mcp.chan);
+            const std::string tree_path = mb_root(mcp.mboard) / "rx_dsps" / mcp.chan;
             if (_tree->exists(tree_path)) {
                 return tree_path;
             } else {
@@ -1818,7 +1818,7 @@ private:
         }
         try
         {
-            const std::string tree_path = mb_root(mcp.mboard) / "tx_dsps" / boost::lexical_cast<std::string>(mcp.chan);
+            const std::string tree_path = mb_root(mcp.mboard) / "tx_dsps" / mcp.chan;
             if (_tree->exists(tree_path)) {
                 return tree_path;
             } else {
diff --git a/host/lib/usrp/n230/n230_eeprom_manager.cpp b/host/lib/usrp/n230/n230_eeprom_manager.cpp
index c21eb9ddb..4a996ef61 100644
--- a/host/lib/usrp/n230/n230_eeprom_manager.cpp
+++ b/host/lib/usrp/n230/n230_eeprom_manager.cpp
@@ -68,9 +68,9 @@ const mboard_eeprom_t& n230_eeprom_manager::read_mb_eeprom()
     uint16_t ver_major = uhd::htonx<uint16_t>(map.data_version_major);
     uint16_t ver_minor = uhd::htonx<uint16_t>(map.data_version_minor);
 
-    _mb_eeprom["product"] = boost::lexical_cast<std::string>(
+    _mb_eeprom["product"] = std::to_string(
         uhd::htonx<uint16_t>(map.hw_product));
-    _mb_eeprom["revision"] = boost::lexical_cast<std::string>(
+    _mb_eeprom["revision"] = std::to_string(
         uhd::htonx<uint16_t>(map.hw_revision));
     //The revision_compat field does not exist in version 1.0
     //EEPROM version 1.0 will only exist on HW revision 1 so it is safe to set
@@ -78,7 +78,7 @@ const mboard_eeprom_t& n230_eeprom_manager::read_mb_eeprom()
     if (ver_major == 1 and ver_minor == 0) {
         _mb_eeprom["revision_compat"] = _mb_eeprom["revision"];
     } else {
-        _mb_eeprom["revision_compat"] = boost::lexical_cast<std::string>(
+        _mb_eeprom["revision_compat"] = std::to_string(
             uhd::htonx<uint16_t>(map.hw_revision_compat));
     }
     _mb_eeprom["serial"] = _bytes_to_string(
diff --git a/host/lib/usrp/n230/n230_resource_manager.cpp b/host/lib/usrp/n230/n230_resource_manager.cpp
index 61a80ae43..d454afd40 100644
--- a/host/lib/usrp/n230/n230_resource_manager.cpp
+++ b/host/lib/usrp/n230/n230_resource_manager.cpp
@@ -26,9 +26,7 @@
 #include <uhd/utils/paths.hpp>
 #include <boost/format.hpp>
 #include <boost/thread.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/functional/hash.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/make_shared.hpp>
 #include "n230_fw_defs.h"
 #include "n230_fw_host_iface.h"
@@ -419,7 +417,7 @@ transport::zero_copy_if::sptr n230_resource_manager::_create_transport(
     default_buff_args.num_send_frames = 32;
 
     transport::zero_copy_if::sptr xport = transport::udp_zero_copy::make(
-        eth_conn.ip_addr, boost::lexical_cast<std::string>(fpga::CVITA_UDP_PORT),
+        eth_conn.ip_addr, std::to_string(fpga::CVITA_UDP_PORT),
         default_buff_args, buff_params_out, buff_params);
 
     if (xport.get()) {
diff --git a/host/lib/usrp/n230/n230_stream_manager.cpp b/host/lib/usrp/n230/n230_stream_manager.cpp
index 95da2752e..0d5aa693f 100644
--- a/host/lib/usrp/n230/n230_stream_manager.cpp
+++ b/host/lib/usrp/n230/n230_stream_manager.cpp
@@ -80,13 +80,13 @@ rx_streamer::sptr n230_stream_manager::get_rx_stream(const uhd::stream_args_t &a
         //TODO: Propagate the device_args class into streamer in the future
         device_addr_t device_addr = args.args;
         if (not device_addr.has_key("recv_buff_size")) {
-            device_addr["recv_buff_size"] = boost::lexical_cast<std::string>(_dev_args.get_recv_buff_size());
+            device_addr["recv_buff_size"] = std::to_string(_dev_args.get_recv_buff_size());
         }
         if (not device_addr.has_key("recv_frame_size")) {
-            device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(_dev_args.get_recv_frame_size());
+            device_addr["recv_frame_size"] = std::to_string(_dev_args.get_recv_frame_size());
         }
         if (not device_addr.has_key("num_recv_frames")) {
-            device_addr["num_recv_frames"] = boost::lexical_cast<std::string>(_dev_args.get_num_recv_frames());
+            device_addr["num_recv_frames"] = std::to_string(_dev_args.get_num_recv_frames());
         }
 
         transport::udp_zero_copy::buff_params buff_params_out;
@@ -170,7 +170,7 @@ rx_streamer::sptr n230_stream_manager::get_rx_stream(const uhd::stream_args_t &a
         if (prop_tree) {
             //TODO: Update this to support multiple motherboards
             const fs_path mb_path = "/mboards/0";
-            prop_tree->access<double>(mb_path / "rx_dsps" / boost::lexical_cast<std::string>(chan) / "rate" / "value").update();
+            prop_tree->access<double>(mb_path / "rx_dsps" / std::to_string(chan) / "rate" / "value").update();
         }
     }
     update_stream_states();
@@ -207,13 +207,13 @@ tx_streamer::sptr n230_stream_manager::get_tx_stream(const uhd::stream_args_t &a
         //TODO: Propagate the device_args class into streamer in the future
         device_addr_t device_addr = args.args;
         if (not device_addr.has_key("send_buff_size")) {
-            device_addr["send_buff_size"] = boost::lexical_cast<std::string>(_dev_args.get_send_buff_size());
+            device_addr["send_buff_size"] = std::to_string(_dev_args.get_send_buff_size());
         }
         if (not device_addr.has_key("send_frame_size")) {
-            device_addr["send_frame_size"] = boost::lexical_cast<std::string>(_dev_args.get_send_frame_size());
+            device_addr["send_frame_size"] = std::to_string(_dev_args.get_send_frame_size());
         }
         if (not device_addr.has_key("num_send_frames")) {
-            device_addr["num_send_frames"] = boost::lexical_cast<std::string>(_dev_args.get_num_send_frames());
+            device_addr["num_send_frames"] = std::to_string(_dev_args.get_num_send_frames());
         }
 
         transport::udp_zero_copy::buff_params buff_params_out;
@@ -295,7 +295,7 @@ tx_streamer::sptr n230_stream_manager::get_tx_stream(const uhd::stream_args_t &a
         if (prop_tree) {
             //TODO: Update this to support multiple motherboards
             const fs_path mb_path = "/mboards/0";
-            prop_tree->access<double>(mb_path / "tx_dsps" / boost::lexical_cast<std::string>(chan) / "rate" / "value").update();
+            prop_tree->access<double>(mb_path / "tx_dsps" / std::to_string(chan) / "rate" / "value").update();
         }
     }
     update_stream_states();
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index 7c479a447..92b7f5331 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -229,7 +229,7 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
     _master_clock_rate = 64e6;
     if (device_addr.has_key("mcr")){
         try{
-            _master_clock_rate = boost::lexical_cast<double>(device_addr["mcr"]);
+            _master_clock_rate = std::stod(device_addr["mcr"]);
         }
         catch(const std::exception &e){
             UHD_LOGGER_ERROR("USRP1") << "Error parsing FPGA clock rate from device address: " << e.what() ;
@@ -237,7 +237,7 @@ usrp1_impl::usrp1_impl(const device_addr_t &device_addr){
     }
     else if (not mb_eeprom["mcr"].empty()){
         try{
-            _master_clock_rate = boost::lexical_cast<double>(mb_eeprom["mcr"]);
+            _master_clock_rate = std::stod(mb_eeprom["mcr"]);
         }
         catch(const std::exception &e){
             UHD_LOGGER_ERROR("USRP1") << "Error parsing FPGA clock rate from EEPROM: " << e.what() ;
diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp
index c05453c40..4a15c641a 100644
--- a/host/lib/usrp/usrp2/clock_ctrl.cpp
+++ b/host/lib/usrp/usrp2/clock_ctrl.cpp
@@ -22,7 +22,6 @@
 #include <uhd/utils/safe_call.hpp>
 #include <uhd/utils/assert_has.hpp>
 #include <stdint.h>
-#include <boost/lexical_cast.hpp>
 #include <boost/math/special_functions/round.hpp>
 #include <iostream>
 
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 9ee13d289..573314339 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -29,7 +29,6 @@
 #include <uhd/utils/byteswap.hpp>
 #include <uhd/utils/safe_call.hpp>
 #include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/bind.hpp>
 #include <boost/assign/list_of.hpp>
 #include <boost/asio/ip/address_v4.hpp>
@@ -334,7 +333,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) :
     if (not device_addr.has_key("send_buff_size")){
         //The buffer should be the size of the SRAM on the device,
         //because we will never commit more than the SRAM can hold.
-        device_addr["send_buff_size"] = boost::lexical_cast<std::string>(USRP2_SRAM_BYTES);
+        device_addr["send_buff_size"] = std::to_string(USRP2_SRAM_BYTES);
     }
 
     device_addrs_t device_args = separate_device_addr(device_addr);
@@ -353,8 +352,8 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) :
             mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu);
         }
 
-        device_addr["recv_frame_size"] = boost::lexical_cast<std::string>(mtu.recv_mtu);
-        device_addr["send_frame_size"] = boost::lexical_cast<std::string>(mtu.send_mtu);
+        device_addr["recv_frame_size"] = std::to_string(mtu.recv_mtu);
+        device_addr["send_frame_size"] = std::to_string(mtu.send_mtu);
 
         UHD_LOGGER_INFO("USRP2") << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu;
         UHD_LOGGER_INFO("USRP2") << boost::format("Current send frame size: %d bytes") % mtu.send_mtu;
@@ -375,7 +374,7 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr) :
 
     for (size_t mbi = 0; mbi < device_args.size(); mbi++){
         const device_addr_t device_args_i = device_args[mbi];
-        const std::string mb = boost::lexical_cast<std::string>(mbi);
+        const std::string mb = std::to_string(mbi);
         const std::string addr = device_args_i["addr"];
         const fs_path mb_path = "/mboards/" + mb;
 
diff --git a/host/lib/usrp/x300/x300_fw_ctrl.cpp b/host/lib/usrp/x300/x300_fw_ctrl.cpp
index 38b7eb139..b8cb2075e 100644
--- a/host/lib/usrp/x300/x300_fw_ctrl.cpp
+++ b/host/lib/usrp/x300/x300_fw_ctrl.cpp
@@ -28,7 +28,6 @@
 #include "x300_regs.hpp"
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/thread/thread.hpp>
-#include <boost/lexical_cast.hpp>
 
 using namespace uhd;
 using namespace uhd::niusrprio;
@@ -299,7 +298,7 @@ protected:
 
     virtual std::string __loc_info(void)
     {
-        return boost::lexical_cast<std::string>(_drv_proxy->get_interface_num());
+        return std::to_string(_drv_proxy->get_interface_num());
     }
 
 private:
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp
index 4601b2789..40288b54c 100644
--- a/host/lib/usrp/x300/x300_impl.cpp
+++ b/host/lib/usrp/x300/x300_impl.cpp
@@ -524,7 +524,7 @@ void x300_impl::mboard_members_t::discover_eth(
 
 void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr)
 {
-    const fs_path mb_path = "/mboards/"+boost::lexical_cast<std::string>(mb_i);
+    const fs_path mb_path = fs_path("/mboards") / mb_i;
     mboard_members_t &mb = _mb[mb_i];
     mb.initialization_done = false;
 
@@ -533,7 +533,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr)
     );
     const std::string thread_msg(
         "Thread ID " + thread_id + " for motherboard "
-        + boost::lexical_cast<std::string>(mb_i)
+        + std::to_string(mb_i)
     );
 
     std::vector<std::string> eth_addrs;
@@ -1204,7 +1204,7 @@ uhd::both_xports_t x300_impl::make_transport(
          * connection type.*/
         size_t eth_data_rec_frame_size = 0;
 
-        fs_path mboard_path = fs_path("/mboards/"+boost::lexical_cast<std::string>(mb_index) / "link_max_rate");
+        fs_path mboard_path = fs_path("/mboards") / mb_index / "link_max_rate";
 
         if (mb.loaded_fpga_image == "HG") {
             size_t max_link_rate = 0;
diff --git a/host/lib/usrp/x300/x300_io_impl.cpp b/host/lib/usrp/x300/x300_io_impl.cpp
index eeff4091f..35d6f74f3 100644
--- a/host/lib/usrp/x300/x300_io_impl.cpp
+++ b/host/lib/usrp/x300/x300_io_impl.cpp
@@ -46,10 +46,10 @@ device_addr_t x300_impl::get_rx_hints(size_t mb_index)
             //For nirio, the buffer size is not configurable by the user
             #if defined(UHD_PLATFORM_MACOS) || defined(UHD_PLATFORM_BSD)
                 //limit buffer resize on macos or it will error
-                rx_hints["recv_buff_size"] = boost::lexical_cast<std::string>(X300_RX_SW_BUFF_SIZE_ETH_MACOS);
+                rx_hints["recv_buff_size"] = std::to_string(X300_RX_SW_BUFF_SIZE_ETH_MACOS);
             #elif defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)
                 //set to half-a-second of buffering at max rate
-                rx_hints["recv_buff_size"] = boost::lexical_cast<std::string>(X300_RX_SW_BUFF_SIZE_ETH);
+                rx_hints["recv_buff_size"] = std::to_string(X300_RX_SW_BUFF_SIZE_ETH);
             #endif
         }
     }
diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp
index 9e3f298d8..50c3059d3 100644
--- a/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp
+++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.hpp
@@ -158,7 +158,7 @@ private:
             misc_ins_reg_t(): uhd::soft_reg64_ro_t(regs::RB_MISC_IO) { }
         } misc_ins_reg;
 
-        radio_regmap_t(int radio_num) : soft_regmap_t("radio" + boost::lexical_cast<std::string>(radio_num) + "_regmap") {
+        radio_regmap_t(int radio_num) : soft_regmap_t("radio" + std::to_string(radio_num) + "_regmap") {
             add_to_map(misc_outs_reg, "misc_outs_reg", PRIVATE);
             add_to_map(misc_ins_reg, "misc_ins_reg", PRIVATE);
         }
diff --git a/host/lib/usrp_clock/octoclock/octoclock_eeprom.cpp b/host/lib/usrp_clock/octoclock/octoclock_eeprom.cpp
index d18f94278..82b3463a8 100644
--- a/host/lib/usrp_clock/octoclock/octoclock_eeprom.cpp
+++ b/host/lib/usrp_clock/octoclock/octoclock_eeprom.cpp
@@ -24,7 +24,6 @@
 #include <uhd/utils/byteswap.hpp>
 #include <boost/assign/list_of.hpp>
 #include <boost/asio.hpp>
-#include <boost/lexical_cast.hpp>
 
 #include <iostream>
 
@@ -84,7 +83,7 @@ void octoclock_eeprom_t::_load(){
         (*this)["name"] = bytes_to_string(name_bytes);
 
         //Revision
-        (*this)["revision"] = boost::lexical_cast<std::string>(int(eeprom_in->revision));
+        (*this)["revision"] = std::to_string(int(eeprom_in->revision));
     }
     else throw uhd::runtime_error("Error loading OctoClock EEPROM.");
 }
diff --git a/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp b/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp
index f317106a3..0e7845be7 100644
--- a/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp
+++ b/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp
@@ -31,7 +31,6 @@
 #include <stdint.h>
 #include <boost/filesystem.hpp>
 #include <boost/format.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/thread.hpp>
 
 #include <algorithm>
diff --git a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp
index 4f2f44add..cea493fb4 100644
--- a/host/lib/usrp_clock/octoclock/octoclock_impl.cpp
+++ b/host/lib/usrp_clock/octoclock/octoclock_impl.cpp
@@ -211,7 +211,7 @@ octoclock_impl::octoclock_impl(const device_addr_t &_device_addr){
                 ) % _get_images_help_message(addr)));
         }
 
-        const std::string oc = boost::lexical_cast<std::string>(oci);
+        const std::string oc = std::to_string(oci);
 
         ////////////////////////////////////////////////////////////////////
         // Set up UDP transports
@@ -234,7 +234,7 @@ octoclock_impl::octoclock_impl(const device_addr_t &_device_addr){
                     "%s\n"
                 ) % int(OCTOCLOCK_FW_COMPAT_NUM) % int(_proto_ver) % _get_images_help_message(addr)));
         }
-        _tree->create<std::string>(oc_path / "fw_version").set(boost::lexical_cast<std::string>(int(_proto_ver)));
+        _tree->create<std::string>(oc_path / "fw_version").set(std::to_string(int(_proto_ver)));
 
         ////////////////////////////////////////////////////////////////////
         // Set up EEPROM
-- 
cgit v1.2.3