diff --git a/src/meta17.lib/meta17/Index.h b/src/meta17.lib/meta17/Index.h index 2cd982e..455caf1 100644 --- a/src/meta17.lib/meta17/Index.h +++ b/src/meta17.lib/meta17/Index.h @@ -12,4 +12,7 @@ using Index = Const; template constexpr auto index = Index{}; +template +constexpr auto _index = Index{}; // index is ambiguous on posix (string.h / strings.h) + } // namespace meta17 diff --git a/src/partial17.lib/partial17/Partial.h b/src/partial17.lib/partial17/Partial.h index c97f9d6..b4ea45e 100644 --- a/src/partial17.lib/partial17/Partial.h +++ b/src/partial17.lib/partial17/Partial.h @@ -18,11 +18,11 @@ namespace partial17 { +using meta17::_index; using meta17::alignOffset; using meta17::checkedIndexOf; using meta17::Const; using meta17::contains_of; -using meta17::index; using meta17::Index; using meta17::index_of; using meta17::index_pack; @@ -179,7 +179,7 @@ struct Partial { using T = UnwrapType; if (hasValue(iv)) { ptr = alignPointer(ptr); - new (ptr) T(factory(index)); + new (ptr) T(factory(_index)); r.whichBits.set(iv); ptr += sizeof(T); } @@ -301,7 +301,7 @@ struct Partial { template constexpr static auto visitIndexTypes(F&& f, IndexPack) { - (f(index, type), ...); + (f(_index, type), ...); } }; diff --git a/src/partial17.lib/partial17/Partial.test.cpp b/src/partial17.lib/partial17/Partial.test.cpp index 6c958d4..d60a472 100644 --- a/src/partial17.lib/partial17/Partial.test.cpp +++ b/src/partial17.lib/partial17/Partial.test.cpp @@ -61,13 +61,13 @@ TEST(Partial, fromFactory) { const auto p = Partial::fromFactory( [](size_t i) { return (0 == i % 2); }, [](auto i) { - if constexpr (i == index<0>) { + if constexpr (i == _index<0>) { return 'a'; } - if constexpr (i == index<1>) { + if constexpr (i == _index<1>) { return 23; } - if constexpr (i == index<2>) { + if constexpr (i == _index<2>) { return 3.14f; } }); @@ -84,11 +84,11 @@ TEST(Partial, type) { ASSERT_TRUE(p.which().of(type)); ASSERT_TRUE(p.which().at(0)); EXPECT_EQ(0x23, p.of(type)); - EXPECT_EQ(0x23, p.at(index<0>)); + EXPECT_EQ(0x23, p.at(_index<0>)); ASSERT_TRUE(p.which().of(type)); ASSERT_TRUE(p.which().at(1)); ASSERT_EQ(23, p.of(type)); - EXPECT_EQ(23, p.at(index<1>)); + EXPECT_EQ(23, p.at(_index<1>)); // TODO CK: Does prevent valid compilation? Microsoft Visual C++ BUG? // auto m = Partial{23, 32}; diff --git a/src/tuple17.lib/tuple17/Tuple.h b/src/tuple17.lib/tuple17/Tuple.h index a23d905..d567763 100644 --- a/src/tuple17.lib/tuple17/Tuple.h +++ b/src/tuple17.lib/tuple17/Tuple.h @@ -165,7 +165,7 @@ struct Tuple { return toValue(meta17::constAt(offsets, indices)); } template - static constexpr auto offset_at = offsetAt(); + static constexpr size_t offset_at = offsetAt(); template static constexpr auto offsetOf(Type = {}) -> size_t { @@ -173,7 +173,7 @@ struct Tuple { return offsetAt(); } template - static constexpr auto offset_of = offsetOf(); + static constexpr size_t offset_of = offsetOf(); template static constexpr auto typeAt(Const = {}) { @@ -182,7 +182,7 @@ struct Tuple { template using TypeAt = decltype(typeAt()); template - static constexpr auto type_at = TypeAt{}; + static constexpr TypeAt type_at = TypeAt{}; template using UnwrapTypeAt = UnwrapType>;