--- /dev/null
+
+#ifndef EC_META_FOR_EACH_HPP
+#define EC_META_FOR_EACH_HPP
+
+#include <tuple>
+#include <utility>
+#include "Morph.hpp"
+
+namespace EC
+{
+ namespace Meta
+ {
+ template <typename Function, typename TTuple, std::size_t... Indices>
+ constexpr void forEachHelper(Function&& function, TTuple tuple, std::index_sequence<Indices...>)
+ {
+ return (void)std::initializer_list<int>{(function(std::get<Indices>(tuple)), 0)...};
+ }
+
+ template <typename TTypeList, typename Function>
+ constexpr void forEach(Function&& function)
+ {
+ using TTuple = EC::Meta::Morph<TTypeList, std::tuple<> >;
+ using TTupleSize = std::tuple_size<TTuple>;
+ using IndexSeq = std::make_index_sequence<TTupleSize::value>;
+
+ return forEachHelper(std::forward<Function>(function), TTuple{}, IndexSeq{});
+ }
+ }
+}
+
+#endif
+
EXPECT_TRUE(isSame);
}
+TEST(Meta, ForEach)
+{
+ EC::Bitset<ListComponentsAll, ListTagsAll> bitset;
+
+ auto setBits = [&bitset] (auto t) {
+ bitset[EC::Meta::IndexOf<decltype(t), ListAll>::value] = true;
+ };
+
+ EC::Meta::forEach<ListComponentsSome>(setBits);
+
+ EXPECT_FALSE(bitset[0]);
+ EXPECT_TRUE(bitset[1]);
+ EXPECT_FALSE(bitset[2]);
+ EXPECT_TRUE(bitset[3]);
+ EXPECT_FALSE(bitset[4]);
+ EXPECT_FALSE(bitset[5]);
+}
+