Skip to content

Commit

Permalink
Use std::addressof to instead of plain '&'.
Browse files Browse the repository at this point in the history
Otherwise the code won't compile if the '&' operater is overloaded and
return something that cannot be casted to void *.
  • Loading branch information
Chaoran Yang committed May 12, 2019
1 parent 5299815 commit 2fc2383
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions googletest/include/gtest/gtest-printers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit 2fc2383

Please sign in to comment.
  NODES
COMMUNITY 1
Note 1
Project 1
USERS 1