]> granicus.if.org Git - pdns/commitdiff
Add static assert to ensure T is unsigned.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2019 08:57:44 +0000 (10:57 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 17 Jul 2019 08:57:44 +0000 (10:57 +0200)
pdns/misc.hh

index 0ead1e41baf62be1f2f489cd05989721fafaed2d..5a8bc2b22b68e4f1531046b7a01b05640d6d2042 100644 (file)
@@ -112,6 +112,7 @@ stringtok (Container &container, string const &in,
 
 template<typename T> bool rfc1982LessThan(T a, T b)
 {
+  static_assert(std::is_unsigned<T>::value, "rfc1982LessThan only works for unsigned types");
   typedef typename std::make_signed<T>::type signed_t;
   return static_cast<signed_t>(a - b) < 0;
 }