diff --git a/src/EC/Meta.hpp b/src/EC/Meta.hpp index e314acf..ab62b74 100644 --- a/src/EC/Meta.hpp +++ b/src/EC/Meta.hpp @@ -33,6 +33,25 @@ namespace EC template using Contains = std::integral_constant::value >; + + template + struct IndexOf + { + }; + + template + struct IndexOf > : + std::integral_constant + { + }; + + template + struct IndexOf > : + std::integral_constant >::value + > + { + }; } } diff --git a/src/test/MetaTest.cpp b/src/test/MetaTest.cpp index e8f64ef..26c32fa 100644 --- a/src/test/MetaTest.cpp +++ b/src/test/MetaTest.cpp @@ -3,14 +3,16 @@ #include +struct C0 {}; +struct C1 {}; +struct C2 {}; +struct C3 {}; + +using listAll = EC::Meta::TypeList; +using listSome = EC::Meta::TypeList; + TEST(Meta, Contains) { - struct C0 {}; - struct C1 {}; - struct C2 {}; - struct C3 {}; - - using listAll = EC::Meta::TypeList; int size = listAll::size; EXPECT_EQ(size, 4); @@ -24,7 +26,6 @@ TEST(Meta, Contains) result = EC::Meta::Contains::value; EXPECT_TRUE(result); - using listSome = EC::Meta::TypeList; size = listSome::size; EXPECT_EQ(size, 2); @@ -37,3 +38,21 @@ TEST(Meta, Contains) result = EC::Meta::Contains::value; EXPECT_TRUE(result); } + +TEST(Meta, IndexOf) +{ + int index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 0); + index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 1); + index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 2); + index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 3); + + index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 0); + index = EC::Meta::IndexOf::value; + EXPECT_EQ(index, 1); +} +