From: Nadav Har'El <[email protected]>
Committer: Nadav Har'El <[email protected]>
Branch: master
Use function overload, not template instantiation
Gcc 6 complains when a static template instance is created, but never used -
just like it complains about regular static functions which are not used.
There was no reason in the first place for these functions to be a template.
They can just be run-of-the-mill overloading of the same function names
with different arguments.
Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
---
diff --git a/include/osv/bitset-iter.hh b/include/osv/bitset-iter.hh
--- a/include/osv/bitset-iter.hh
+++ b/include/osv/bitset-iter.hh
@@ -16,48 +16,27 @@ namespace bitsets {
static constexpr int ulong_bits = std::numeric_limits<unsigned
long>::digits;
/**
- * Returns the number of leading zeros in value's binary representation.
- *
- * If value == 0 the result is undefied. If T is signed and value is
negative
- * the result is undefined.
- *
- * The highest value that can be returned is
std::numeric_limits<T>::digits - 1,
- * which is returned when value == 1.
- */
-template<typename T>
-static inline size_t count_leading_zeros(T value);
-
-/**
* Returns the number of trailing zeros in value's binary representation.
*
* If value == 0 the result is undefied. If T is signed and value is
negative
* the result is undefined.
*
* The highest value that can be returned is
std::numeric_limits<T>::digits - 1.
*/
-template<typename T>
-static inline size_t count_trailing_zeros(T value);
-
-template<>
-size_t count_leading_zeros<unsigned long>(unsigned long value)
+static inline size_t count_leading_zeros(unsigned long value)
{
return __builtin_clzl(value);
}
-
-template<>
-size_t count_leading_zeros<long>(long value)
+static inline size_t count_leading_zeros(long value)
{
return __builtin_clzl((unsigned long)value) - 1;
}
-
-template<>
-size_t count_trailing_zeros<unsigned long>(unsigned long value)
+static inline size_t count_trailing_zeros(unsigned long value)
{
return __builtin_ctzl(value);
}
-template<>
-size_t count_trailing_zeros<long>(long value)
+static inline size_t count_trailing_zeros(long value)
{
return __builtin_ctzl((unsigned long)value);
}
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.