Fix VR surface attributes.
VR surface attributes had two issues that prevented the full extent of their use: 1. The older clang version missed that templated copy constructor and assignment operators do not override the default ones in the Variant class. This caused issues with certain types when copy constructing / assigning from another Variant of the same type. This was noticed by running tests with a newer version of clang which provided warnings. 2. C++ rules about implicit conversion to bool from types that decay to pointers causes subtle issues with Variants that have bool elements. For example this assignment compiles but produces the wrong result: const int array[3] = { 1, 2, 3}; Variant<int, bool, std::array<int, 3>> variant = array; EXPECT_FALSE(variant.is<bool>()); // Actually true. Here the programmer might accidentally think that the std::array element of the variant can be assigned from the regular array. This doesn't work, but instead the compiler decays the array to a pointer and assigns the bool element to true. The first issue is addressed by defining copy/move constructors / assignment operators on Variant and deleting the default ones from the internal Union type for extra safety. The second issue is addressed by making a more restrictive version of the std::is_constructible trait that rejects bool construction from types that decay to pointers. Once this was put in place the erroneous use cases no longer compiled and is fixed as part of this CL. Tests are updated to verify the fixes to these issues. Bug: 62557221 Test: pdx_tests and dvr_api-test passes. Change-Id: Id4647e54e0a7b1753217fe7fe351462fe5bcfd83
Loading
Please register or sign in to comment