From f47df4d1a83289043ef40469141aaa03d0c60d35 Mon Sep 17 00:00:00 2001 From: Lane Kolbly Date: Fri, 9 Jul 2021 17:02:06 -0500 Subject: host: Add static_assert to prevent meta_range_t(0,0) meta_range_t(0,0) actually calls the iterator-based constructor for meta_range_t, which is almost certainly not the intended constructor for that call syntax. Therefore, we add a static_assert to prevent such usage, and fix all failing instances. --- host/include/uhd/types/ranges.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'host/include') diff --git a/host/include/uhd/types/ranges.hpp b/host/include/uhd/types/ranges.hpp index 361b0e9d3..05aa0fa7c 100644 --- a/host/include/uhd/types/ranges.hpp +++ b/host/include/uhd/types/ranges.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace uhd { @@ -76,6 +77,14 @@ struct UHD_API meta_range_t : std::vector meta_range_t(InputIterator first, InputIterator last) : std::vector(first, last) { /* NOP */ + // This is to avoid people accidentally doing silly things like: + // meta_range_t(0, 0) + // which probably was supposed to call meta_range_t(double, double, double) + // but actually calls this constructor. + static_assert( + !std::is_integral::type>::value, + "You can't pass integers to meta_range_t's constructor!" + ); } /*! -- cgit v1.2.3