Changes in src/Common/utility.h [b6d7f44:f14d956]
- File:
-
- 1 edited
-
src/Common/utility.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
rb6d7f44 rf14d956 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:24:16201813 // Update Count : 4012 // Last Modified On : Fri Apr 20 22:35:33 2018 13 // Update Count : 38 14 14 // 15 15 … … 441 441 442 442 template<typename T> 443 inline 444 #if defined(__GNUC__) && __GNUC__ > 4 445 constexpr 446 #endif 447 T ilog2(const T & t) { 448 if(std::is_integral<T>::value) { 443 inline constexpr T ilog2(const T & t) { 444 if ( std::is_integral<T>::value ) { 449 445 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 455 450 return -1; 456 } // ilo g2451 } // ilong2 457 452 458 453
Note:
See TracChangeset
for help on using the changeset viewer.