-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Closed
Closed
Copy link
Labels
Description
In some cases, clang-tidy reports a false-positive misc-redundant-expression for fold expressions that contain the same value more than once (https://godbolt.org/z/YfThnE9Wh):
#include <type_traits>
template<typename... Args>
constexpr bool all_true = (... && Args::value);
constexpr bool result = all_true<std::true_type, std::true_type, std::true_type>;Output:
<source>:4:28: warning: both sides of operator are equivalent [misc-redundant-expression]
4 | constexpr bool all_true = (... && Args::value);
|
Strictly speaking the warning is correct, but I would not expect clang-tidy to complain here.
When all_true is implemented as a function, clang-tidy does not report anything:
#include <type_traits>
template<typename... Args>
constexpr bool all_true() {
return (... && Args::value);
}
constexpr bool result = all_true<std::true_type, std::true_type, std::true_type>();