
Murillo, please don't top post. ----- Original Message ----- From: "Murilo Adriano Vasconcelos" <muriloufg@gmail.com> To: <boost@lists.boost.org> Sent: Wednesday, July 14, 2010 10:43 PM Subject: Re: [boost] Bits and Ints: Intention Request
But maybe it can be a good point to use enable_if<> to for 8 and 16-bit integrals specializations and use the correct __builtin for the others like:
template <typename T> inline int count_leading_zeros(T value) { #ifndef BOOST_HAS_NO_INT64_T return __builtin_clzll(value) - (64 - (sizeof(T) << 3)); #else return __builtin_clz(value) - (32 - (sizeof(T) << 3)); #endif }
I gess the above code should be replace by the following one, when GNUC is defined, isn't it?
template<> inline int count_leading_zeros(unsigned int value) { return __builtin_clz(value); }
template<> inline int count_leading_zeros(unsigned long int value) { return __builtin_clzl(value); }
template<> inline int count_leading_zeros(unsigned long long int value) { return __builtin_clzll(value); }
What do you think?
Instead of function template specialization you can just use overloading. So the you can remove the 'template<>' Best, Vicente