SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Misc.h
Go to the documentation of this file.
1
18#ifndef _SEUTILS_MISC_H_
19#define _SEUTILS_MISC_H_
20
21#include <type_traits>
22
23namespace SourceXtractor {
24
25template <typename T>
27 static_assert(std::is_unsigned<T>::value, "Type T must be unsigned");
28 v--;
29 for (size_t i = 1; i < sizeof(v) * 8U; i *= 2) {
30 v |= v >> i;
31 }
32 v++;
33 return v;
34}
35
36}
37
38#endif /* _SEUTILS_MISC_H_ */
T nextPowerOfTwo(T v)
Definition Misc.h:26