mirror of
https://github.com/google/googletest.git
synced 2026-06-15 08:26:11 +08:00
Merge 9fec814a9a1459b88fec7b569db99ccb12d5362b into 7140cd416cecd7462a8aae488024abeee55598e4
This commit is contained in:
commit
db2b8d188e
@ -43,6 +43,7 @@
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
@ -403,11 +404,9 @@ class [[nodiscard]] MatcherBase : private MatcherDescriberInterface {
|
||||
template <typename M, bool = MatcherBase::IsInlined<M>()>
|
||||
struct ValuePolicy {
|
||||
static const M& Get(const MatcherBase& m) {
|
||||
// When inlined along with Init, need to be explicit to avoid violating
|
||||
// When inlined along with Init, need to be laundered to avoid violating
|
||||
// strict aliasing rules.
|
||||
const M* ptr =
|
||||
static_cast<const M*>(static_cast<const void*>(&m.buffer_));
|
||||
return *ptr;
|
||||
return *std::launder(reinterpret_cast<const M*>(&m.buffer_));
|
||||
}
|
||||
static void Init(MatcherBase& m, M impl) {
|
||||
::new (static_cast<void*>(&m.buffer_)) M(impl);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user