From 1fe98e8701dd0b790b172762c3629db32956d1fc Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 28 Sep 2019 11:18:57 +0200 Subject: uhd: Replace usage of boost smart pointers with C++11 counterparts This removes the following Boost constructs: - boost::shared_ptr, boost::weak_ptr - boost::enable_shared_from_this - boost::static_pointer_cast, boost::dynamic_pointer_cast The appropriate includes were also removed. All C++11 versions of these require #include . Note that the stdlib and Boost versions have the exact same syntax, they only differ in the namespace (boost vs. std). The modifications were all done using sed, with the exception of boost::scoped_ptr, which was replaced by std::unique_ptr. References to boost::smart_ptr were also removed. boost::intrusive_ptr is not removed in this commit, since it does not have a 1:1 mapping to a C++11 construct. --- host/examples/benchmark_streamer.cpp | 2 +- host/examples/network_relay.cpp | 16 ++++++++-------- host/examples/rfnoc_radio_loopback.cpp | 2 +- host/examples/txrx_loopback_to_file.cpp | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'host/examples') diff --git a/host/examples/benchmark_streamer.cpp b/host/examples/benchmark_streamer.cpp index c2f3a4b2c..093d4254f 100644 --- a/host/examples/benchmark_streamer.cpp +++ b/host/examples/benchmark_streamer.cpp @@ -514,7 +514,7 @@ test_results benchmark_tx_streamer(uhd::device3::sptr usrp, const double duration, const std::string& format) { - std::vector> null_ctrls; + std::vector> null_ctrls; for (const auto& id : null_ids) { null_ctrls.push_back(usrp->get_block_ctrl(id)); } diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index bf2ac9255..6de268aa9 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -22,7 +22,7 @@ namespace po = boost::program_options; namespace asio = boost::asio; -typedef boost::shared_ptr socket_type; +typedef std::shared_ptr socket_type; static const size_t insane_mtu = 9000; @@ -81,7 +81,7 @@ public: asio::ip::udp::resolver::query query(asio::ip::udp::v4(), server_addr, port); asio::ip::udp::endpoint endpoint = *resolver.resolve(query); - _server_socket = boost::shared_ptr( + _server_socket = std::shared_ptr( new asio::ip::udp::socket(_io_service, endpoint)); resize_buffs(_server_socket, server_rx_size, server_tx_size); } @@ -90,7 +90,7 @@ public: asio::ip::udp::resolver::query query(asio::ip::udp::v4(), client_addr, port); asio::ip::udp::endpoint endpoint = *resolver.resolve(query); - _client_socket = boost::shared_ptr( + _client_socket = std::shared_ptr( new asio::ip::udp::socket(_io_service)); _client_socket->open(asio::ip::udp::v4()); _client_socket->connect(endpoint); @@ -215,14 +215,14 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) } { - boost::shared_ptr ctrl(new udp_relay_type(bind, addr, "49152")); - boost::shared_ptr rxdsp0(new udp_relay_type( + std::shared_ptr ctrl(new udp_relay_type(bind, addr, "49152")); + std::shared_ptr rxdsp0(new udp_relay_type( bind, addr, "49156", 0, tx_dsp_buff_size, rx_dsp_buff_size, 0)); - boost::shared_ptr txdsp0(new udp_relay_type( + std::shared_ptr txdsp0(new udp_relay_type( bind, addr, "49157", tx_dsp_buff_size, 0, 0, tx_dsp_buff_size)); - boost::shared_ptr rxdsp1(new udp_relay_type( + std::shared_ptr rxdsp1(new udp_relay_type( bind, addr, "49158", 0, tx_dsp_buff_size, rx_dsp_buff_size, 0)); - boost::shared_ptr gps(new udp_relay_type(bind, addr, "49172")); + std::shared_ptr gps(new udp_relay_type(bind, addr, "49172")); std::signal(SIGINT, &sig_int_handler); std::cout << "Press Ctrl + C to stop streaming..." << std::endl; diff --git a/host/examples/rfnoc_radio_loopback.cpp b/host/examples/rfnoc_radio_loopback.cpp index dffe30b3b..707c957e2 100644 --- a/host/examples/rfnoc_radio_loopback.cpp +++ b/host/examples/rfnoc_radio_loopback.cpp @@ -88,7 +88,7 @@ int UHD_SAFE_MAIN(int argc, char* argv[]) std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; - auto dev = boost::dynamic_pointer_cast(uhd::device::make(args)); + auto dev = std::dynamic_pointer_cast(uhd::device::make(args)); if (not dev) { std::cout << "Error: Could not find an RFNoC-compatible device." << std::endl; return EXIT_FAILURE; diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp index 271d249f6..6199ca429 100644 --- a/host/examples/txrx_loopback_to_file.cpp +++ b/host/examples/txrx_loopback_to_file.cpp @@ -117,10 +117,10 @@ void recv_to_file(uhd::usrp::multi_usrp::sptr usrp, // Create one ofstream object per channel // (use shared_ptr because ofstream is non-copyable) - std::vector> outfiles; + std::vector> outfiles; for (size_t i = 0; i < buffs.size(); i++) { const std::string this_filename = generate_out_filename(file, buffs.size(), i); - outfiles.push_back(boost::shared_ptr( + outfiles.push_back(std::shared_ptr( new std::ofstream(this_filename.c_str(), std::ofstream::binary))); } UHD_ASSERT_THROW(outfiles.size() == buffs.size()); -- cgit v1.2.3