Boost logo

Boost :

Subject: Re: [boost] Bits and Ints: Intention Request
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-07-14 17:01:23


Murillo, please don't top post.
----- Original Message -----
From: "Murilo Adriano Vasconcelos" <muriloufg_at_[hidden]>
To: <boost_at_[hidden]>
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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk