projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
constexpr_log2
[folly.git]
/
folly
/
portability
/
Constexpr.h
diff --git
a/folly/portability/Constexpr.h
b/folly/portability/Constexpr.h
index 0b5c5a1a59b80ad7bcd9be3342e5bd885add6fbe..a7620918bf5519eed75eeb0c56407f3c46516018 100644
(file)
--- a/
folly/portability/Constexpr.h
+++ b/
folly/portability/Constexpr.h
@@
-81,6
+81,11
@@
constexpr auto constexpr_abs(T t)
return detail::constexpr_abs_helper<T>::go(t);
}
+template <typename T>
+constexpr T constexpr_log2(T t) {
+ return t == T(1) ? T(0) : T(1) + constexpr_log2(t / T(2));
+}
+
namespace detail {
template <typename Char>