diff options
author | Marcus Müller <mmueller@gnuradio.org> | 2021-10-19 20:44:11 +0200 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-10-28 17:23:25 -0400 |
commit | 041f44e809f39d0567f6f191284d555cd6d08de2 (patch) | |
tree | 053b622cd4f9fef7c7956dd981dd5a7103249b39 | |
parent | 50d00f108c3ad62cd7beed6a4cbfdf4f0321c5aa (diff) |
Replace boost::any with std::any
This is a modernization possible through C++17
Fixes #4780
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
-rw-r--r-- | gnuradio-runtime/include/gnuradio/thread/thread_group.h | 1 | ||||
-rw-r--r-- | gnuradio-runtime/include/pmt/pmt.h | 13 | ||||
-rw-r--r-- | gnuradio-runtime/lib/block_registry.cc | 3 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt.cc | 17 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/pmt_int.h | 10 | ||||
-rw-r--r-- | gnuradio-runtime/lib/pmt/qa_pmt_prims.cc | 15 | ||||
-rw-r--r-- | gnuradio-runtime/python/pmt/__init__.py | 2 | ||||
-rw-r--r-- | gr-digital/include/gnuradio/digital/constellation.h | 4 | ||||
-rw-r--r-- | gr-digital/lib/constellation_receiver_cb_impl.cc | 8 | ||||
-rw-r--r-- | gr-digital/python/digital/bindings/constellation_python.cc | 2 |
10 files changed, 37 insertions, 38 deletions
diff --git a/gnuradio-runtime/include/gnuradio/thread/thread_group.h b/gnuradio-runtime/include/gnuradio/thread/thread_group.h index 9895068373..425858636f 100644 --- a/gnuradio-runtime/include/gnuradio/thread/thread_group.h +++ b/gnuradio-runtime/include/gnuradio/thread/thread_group.h @@ -17,7 +17,6 @@ #include <gnuradio/api.h> #include <gnuradio/thread/thread.h> -#include <boost/any.hpp> #include <boost/core/noncopyable.hpp> #include <boost/function.hpp> #include <boost/thread/shared_mutex.hpp> diff --git a/gnuradio-runtime/include/pmt/pmt.h b/gnuradio-runtime/include/pmt/pmt.h index b55cc57d9f..7afdb92288 100644 --- a/gnuradio-runtime/include/pmt/pmt.h +++ b/gnuradio-runtime/include/pmt/pmt.h @@ -12,8 +12,8 @@ #define INCLUDED_PMT_H #include <pmt/api.h> -#include <boost/any.hpp> #include <boost/noncopyable.hpp> +#include <any> #include <complex> #include <cstdint> #include <iosfwd> @@ -664,10 +664,9 @@ PMT_API pmt_t dict_values(pmt_t dict); /* * ------------------------------------------------------------------------ - * Any (wraps boost::any -- can be used to wrap pretty much anything) + * Any (wraps std::any -- can be used to wrap pretty much anything) * * Cannot be serialized or used across process boundaries. - * See http://www.boost.org/doc/html/any.html * ------------------------------------------------------------------------ */ @@ -675,13 +674,13 @@ PMT_API pmt_t dict_values(pmt_t dict); PMT_API bool is_any(pmt_t obj); //! make an any -PMT_API pmt_t make_any(const boost::any& any); +PMT_API pmt_t make_any(const std::any& any); -//! Return underlying boost::any -PMT_API boost::any any_ref(pmt_t obj); +//! Return underlying std::any +PMT_API std::any any_ref(pmt_t obj); //! Store \p any in \p obj -PMT_API void any_set(pmt_t obj, const boost::any& any); +PMT_API void any_set(pmt_t obj, const std::any& any); /* diff --git a/gnuradio-runtime/lib/block_registry.cc b/gnuradio-runtime/lib/block_registry.cc index a32c0e6801..9ba79c924a 100644 --- a/gnuradio-runtime/lib/block_registry.cc +++ b/gnuradio-runtime/lib/block_registry.cc @@ -13,6 +13,7 @@ #include <gnuradio/block_detail.h> #include <gnuradio/block_registry.h> #include <gnuradio/tpb_detail.h> +#include <any> gr::block_registry global_block_registry; @@ -96,7 +97,7 @@ basic_block_sptr block_registry::block_lookup(pmt::pmt_t symbol) if (pmt::eq(ref, pmt::PMT_NIL)) { throw std::runtime_error("block lookup failed! block not found!"); } - basic_block* blk = boost::any_cast<basic_block*>(pmt::any_ref(ref)); + basic_block* blk = std::any_cast<basic_block*>(pmt::any_ref(ref)); return blk->shared_from_this(); } diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc index d4ada683f9..043b9eb6a6 100644 --- a/gnuradio-runtime/lib/pmt/pmt.cc +++ b/gnuradio-runtime/lib/pmt/pmt.cc @@ -16,6 +16,7 @@ #include <gnuradio/messages/msg_accepter.h> #include <pmt/pmt.h> #include <pmt/pmt_pool.h> +#include <any> #include <cstdio> #include <cstring> #include <vector> @@ -741,20 +742,20 @@ pmt_t dict_values(pmt_t dict) // Any //////////////////////////////////////////////////////////////////////////// -pmt_any::pmt_any(const boost::any& any) : d_any(any) {} +pmt_any::pmt_any(const std::any& any) : d_any(any) {} bool is_any(pmt_t obj) { return obj->is_any(); } -pmt_t make_any(const boost::any& any) { return pmt_t(new pmt_any(any)); } +pmt_t make_any(const std::any& any) { return pmt_t(new pmt_any(any)); } -boost::any any_ref(pmt_t obj) +std::any any_ref(pmt_t obj) { if (!obj->is_any()) throw wrong_type("pmt_any_ref", obj); return _any(obj)->ref(); } -void any_set(pmt_t obj, const boost::any& any) +void any_set(pmt_t obj, const std::any& any) { if (!obj->is_any()) throw wrong_type("pmt_any_set", obj); @@ -770,8 +771,8 @@ bool is_msg_accepter(const pmt_t& obj) if (!is_any(obj)) return false; - boost::any r = any_ref(obj); - return boost::any_cast<gr::messages::msg_accepter_sptr>(&r) != 0; + std::any r = any_ref(obj); + return std::any_cast<gr::messages::msg_accepter_sptr>(&r) != 0; } //! make a msg_accepter @@ -781,8 +782,8 @@ pmt_t make_msg_accepter(gr::messages::msg_accepter_sptr ma) { return make_any(ma gr::messages::msg_accepter_sptr msg_accepter_ref(const pmt_t& obj) { try { - return boost::any_cast<gr::messages::msg_accepter_sptr>(any_ref(obj)); - } catch (boost::bad_any_cast& e) { + return std::any_cast<gr::messages::msg_accepter_sptr>(any_ref(obj)); + } catch (std::bad_any_cast& e) { throw wrong_type("pmt_msg_accepter_ref", obj); } } diff --git a/gnuradio-runtime/lib/pmt/pmt_int.h b/gnuradio-runtime/lib/pmt/pmt_int.h index 7aadefe4d7..1c4b149a49 100644 --- a/gnuradio-runtime/lib/pmt/pmt_int.h +++ b/gnuradio-runtime/lib/pmt/pmt_int.h @@ -11,7 +11,7 @@ #define INCLUDED_PMT_INT_H #include <pmt/pmt.h> -#include <boost/any.hpp> +#include <any> /* * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION! @@ -170,15 +170,15 @@ public: class pmt_any : public pmt_base { - boost::any d_any; + std::any d_any; public: - pmt_any(const boost::any& any); + pmt_any(const std::any& any); //~pmt_any(); bool is_any() const override { return true; } - const boost::any& ref() const { return d_any; } - void set(const boost::any& any) { d_any = any; } + const std::any& ref() const { return d_any; } + void set(const std::any& any) { d_any = any; } }; diff --git a/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc b/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc index f74dd2f7f9..7219f6f099 100644 --- a/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc +++ b/gnuradio-runtime/lib/pmt/qa_pmt_prims.cc @@ -12,6 +12,7 @@ #include <pmt/api.h> //reason: suppress warnings #include <boost/format.hpp> #include <boost/test/unit_test.hpp> +#include <any> #include <cstring> #include <sstream> @@ -455,9 +456,9 @@ std::ostream& operator<<(std::ostream& os, const foo obj) BOOST_AUTO_TEST_CASE(test_any) { - boost::any a0; - boost::any a1; - boost::any a2; + std::any a0; + std::any a1; + std::any a2; a0 = std::string("Hello!"); a1 = 42; @@ -468,11 +469,11 @@ BOOST_AUTO_TEST_CASE(test_any) pmt::pmt_t p2 = pmt::make_any(a2); BOOST_CHECK_EQUAL(std::string("Hello!"), - boost::any_cast<std::string>(pmt::any_ref(p0))); + std::any_cast<std::string>(pmt::any_ref(p0))); - BOOST_CHECK_EQUAL(42, boost::any_cast<int>(pmt::any_ref(p1))); + BOOST_CHECK_EQUAL(42, std::any_cast<int>(pmt::any_ref(p1))); - BOOST_CHECK_EQUAL(foo(3.250, 21), boost::any_cast<foo>(pmt::any_ref(p2))); + BOOST_CHECK_EQUAL(foo(3.250, 21), std::any_cast<foo>(pmt::any_ref(p2))); } // ------------------------------------------------------------------------ @@ -491,7 +492,7 @@ BOOST_AUTO_TEST_CASE(test_msg_accepter) { pmt::pmt_t sym = pmt::mp("my-symbol"); - boost::any a0; + std::any a0; a0 = std::string("Hello!"); pmt::pmt_t p0 = pmt::make_any(a0); diff --git a/gnuradio-runtime/python/pmt/__init__.py b/gnuradio-runtime/python/pmt/__init__.py index 9b313330b0..d654ad542c 100644 --- a/gnuradio-runtime/python/pmt/__init__.py +++ b/gnuradio-runtime/python/pmt/__init__.py @@ -24,7 +24,7 @@ more flexible. The PMT library supports the following major types: bool, symbol (string), integer, real, complex, null, pair, list, -vector, dict, uniform_vector, any (boost::any cast) +vector, dict, uniform_vector, any (std::any cast) ''' diff --git a/gr-digital/include/gnuradio/digital/constellation.h b/gr-digital/include/gnuradio/digital/constellation.h index d6d39353d8..037075f2bb 100644 --- a/gr-digital/include/gnuradio/digital/constellation.h +++ b/gr-digital/include/gnuradio/digital/constellation.h @@ -15,7 +15,7 @@ #include <gnuradio/digital/metric_type.h> #include <gnuradio/gr_complex.h> #include <pmt/pmt.h> -#include <boost/any.hpp> +#include <any> #include <vector> namespace gr { @@ -113,7 +113,7 @@ public: constellation_sptr base() { return shared_from_this(); } - pmt::pmt_t as_pmt() { return pmt::make_any(boost::any(base())); } + pmt::pmt_t as_pmt() { return pmt::make_any(std::any(base())); } /*! \brief Generates the soft decision LUT based on * constellation and symbol map. diff --git a/gr-digital/lib/constellation_receiver_cb_impl.cc b/gr-digital/lib/constellation_receiver_cb_impl.cc index f11de55181..1d2f614035 100644 --- a/gr-digital/lib/constellation_receiver_cb_impl.cc +++ b/gr-digital/lib/constellation_receiver_cb_impl.cc @@ -18,9 +18,7 @@ #include <gnuradio/expj.h> #include <gnuradio/io_signature.h> #include <gnuradio/math.h> - -#include <boost/format.hpp> - +#include <any> #include <stdexcept> namespace gr { @@ -90,9 +88,9 @@ void constellation_receiver_cb_impl::handle_set_constellation( pmt::pmt_t constellation_pmt) { if (pmt::is_any(constellation_pmt)) { - boost::any constellation_any = pmt::any_ref(constellation_pmt); + std::any constellation_any = pmt::any_ref(constellation_pmt); constellation_sptr constellation = - boost::any_cast<constellation_sptr>(constellation_any); + std::any_cast<constellation_sptr>(constellation_any); set_constellation(constellation); } else { GR_LOG_ERROR(d_logger, "Received constellation that is not a PMT any; skipping."); diff --git a/gr-digital/python/digital/bindings/constellation_python.cc b/gr-digital/python/digital/bindings/constellation_python.cc index 4172bc550f..b9e28067c2 100644 --- a/gr-digital/python/digital/bindings/constellation_python.cc +++ b/gr-digital/python/digital/bindings/constellation_python.cc @@ -14,7 +14,7 @@ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ /* BINDTOOL_HEADER_FILE(constellation.h) */ -/* BINDTOOL_HEADER_FILE_HASH(096509fbce3ab57c42e63e4c4c15c6f6) */ +/* BINDTOOL_HEADER_FILE_HASH(0dd35633df785034ea38ce7065495486) */ /***********************************************************************************/ #include <pybind11/complex.h> |