libpdx: Decay variant types to correctly handle cv-reference types.
Decay the types used internally for storage in Variant and update
type matching logic to handle the decayed types.
Bug: 36401174
Test: build; pdx_tests passes.
Change-Id: I93c68cce47d6f7d195b901afe3e63685befc08fe
diff --git a/libs/vr/libpdx/variant_tests.cpp b/libs/vr/libpdx/variant_tests.cpp
index c30c055..325f33f 100644
--- a/libs/vr/libpdx/variant_tests.cpp
+++ b/libs/vr/libpdx/variant_tests.cpp
@@ -368,6 +368,13 @@
}
{
+ TestType<int> i(1);
+ Variant<int, bool, float> v(i.get());
+ ASSERT_TRUE(v.is<int>());
+ EXPECT_EQ(1, std::get<int>(v));
+ }
+
+ {
TestType<bool> b(true);
Variant<int, bool, float> v(b.take());
ASSERT_TRUE(v.is<bool>());
@@ -375,6 +382,13 @@
}
{
+ TestType<bool> b(true);
+ Variant<int, bool, float> v(b.get());
+ ASSERT_TRUE(v.is<bool>());
+ EXPECT_EQ(true, std::get<bool>(v));
+ }
+
+ {
Variant<const char*> c("test");
Variant<std::string> s(c);
ASSERT_TRUE(s.is<std::string>());
@@ -1060,8 +1074,8 @@
EXPECT_FALSE((detail::HasType<char, int, float, bool>::value));
EXPECT_FALSE(detail::HasType<>::value);
- EXPECT_TRUE((detail::HasTypeIgnoreRef<int&, int, float, bool>::value));
- EXPECT_FALSE((detail::HasTypeIgnoreRef<char&, int, float, bool>::value));
+ EXPECT_TRUE((detail::HasType<int&, int, float, bool>::value));
+ EXPECT_FALSE((detail::HasType<char&, int, float, bool>::value));
}
TEST(Variant, Set) {