Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions envpool/core/tuple_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ template <class T, class Tuple>
struct Index;

template <class T, class... Types>
struct Index<T, std::tuple<T, Types...>> {
static constexpr std::size_t kValue = 0;
};

template <class T, class U, class... Types>
struct Index<T, std::tuple<U, Types...>> {
static constexpr std::size_t kValue =
1 + Index<T, std::tuple<Types...>>::kValue;
struct Index<T, std::tuple<Types...>> {
static_assert((std::is_same_v<T, Types> || ...), "Type not found in tuple");
static constexpr std::size_t kValue = [] {
std::size_t i = 0;
((std::is_same_v<T, Types> ? false : (++i, true)) && ...);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rewrite fold so Index does not trip clang-diagnostic-unused-value

.github/workflows/test.yml runs make clang-tidy, and .clang-tidy promotes every warning to an error (WarningsAsErrors: '*'). This fold expression now emits clang-diagnostic-unused-value for each Index<...> instantiation because the (++i, true) branch's value is discarded; I reproduced it with clang-tidy /tmp/index_test.cc -- -std=c++17 -I/workspace/envpool. Since Index is the helper behind Take() in envpool/core/dict.h, ordinary dict lookups will start failing the lint job.

Useful? React with 👍 / 👎.

return i;
}();
};

template <class F, class K, class V, std::size_t... I>
Expand Down
Loading