Changes in / [7ca8441c:fb16d5c]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r7ca8441c rfb16d5c  
    441441
    442442template<typename T>
    443 inline
    444 #if __GNUC__ > 4
    445 constexpr
    446 #endif
    447 T ilog2(const T & t) {
    448         if(std::is_integral<T>::value) {
     443inline constexpr T ilog2(const T & t) {
     444        if ( std::is_integral<T>::value ) {
    449445                const constexpr int r = sizeof(t) * __CHAR_BIT__ - 1;
    450                 if( sizeof(T) == sizeof(unsigned       int) ) return r - __builtin_clz  ( t );
    451                 if( sizeof(T) == sizeof(unsigned      long) ) return r - __builtin_clzl ( t );
    452                 if( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t );
    453         }
    454         assert(false);
     446                if ( sizeof(T) == sizeof(unsigned int ) ) return r - __builtin_clz( t );
     447                if ( sizeof(T) == sizeof(unsigned long) ) return r - __builtin_clzl( t );
     448                if ( sizeof(T) == sizeof(unsigned long long) ) return r - __builtin_clzll( t );
     449        } // if
    455450        return -1;
    456 } // iLog2
     451} // ilong2
    457452
    458453
Note: See TracChangeset for help on using the changeset viewer.