[llvm] r354055 - Optional specialization for trivially copyable types, part2
Serge Guelton via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 14 11:41:44 PST 2019
Author: serge_sans_paille
Date: Thu Feb 14 11:41:44 2019
New Revision: 354055
URL: http://llvm.org/viewvc/llvm-project?rev=354055&view=rev
Log:
Optional specialization for trivially copyable types, part2
Modified:
llvm/trunk/include/llvm/ADT/Optional.h
Modified: llvm/trunk/include/llvm/ADT/Optional.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Optional.h?rev=354055&r1=354054&r2=354055&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Optional.h (original)
+++ llvm/trunk/include/llvm/ADT/Optional.h Thu Feb 14 11:41:44 2019
@@ -116,7 +116,9 @@ template <typename T> struct OptionalSto
OptionalStorage() = default;
- OptionalStorage(const T &y) : hasVal(true) { new (storage.buffer) T(y); }
+ OptionalStorage(const T &y) : hasVal(true) {
+ std::memcpy(storage.buffer, reinterpret_cast<char const *>(&y), sizeof(T));
+ }
OptionalStorage(const OptionalStorage &O) = default;
OptionalStorage(T &&y) : hasVal(true) {
std::memcpy(storage.buffer, reinterpret_cast<char*>(&y), sizeof(T));
More information about the llvm-commits
mailing list