Skip to content

Commit

Permalink
Merge pull request #1514 from GeorgeWeb/georgi/restrict-ur-power-of-2…
Browse files Browse the repository at this point in the history
…-hepler

[UR] Restrict accepted types for the argument of isPowerOf2 to integral
  • Loading branch information
kbenzie authored Apr 17, 2024
2 parents 3f5f568 + 02bb629 commit 7611542
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/ur/ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ roundToHighestFactorOfGlobalSize(size_t &ThreadsPerBlockInDim,
}

// Returns whether or not Value is a power of 2
template <typename T> inline bool isPowerOf2(const T &Value) {
template <typename T, typename = std::enable_if_t<std::is_integral_v<T>>>
bool isPowerOf2(const T &Value) {
return Value && !(Value & (Value - 1));
}

Expand Down

0 comments on commit 7611542

Please sign in to comment.