Use std::addressof to instead of plain '&'.

Otherwise the code won't compile if the '&' operater is overloaded and
return something that cannot be casted to void *.
This commit is contained in:
Chaoran Yang 2019-05-12 00:14:54 +00:00
parent 261cb16318
commit bc887befb7

View File

@ -152,8 +152,8 @@ class TypeWithoutFormatter {
// This default version is called when kTypeKind is kOtherType.
static void PrintValue(const T& value, ::std::ostream* os) {
PrintBytesInObjectTo(static_cast<const unsigned char*>(
reinterpret_cast<const void*>(&value)),
sizeof(value), os);
reinterpret_cast<const void*>(
std::addressof(value))), sizeof(value), os);
}
};