projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
72c3b1e
)
Optional specialization for trivially copyable types, part2
author
Serge Guelton
<sguelton@redhat.com>
Thu, 14 Feb 2019 19:41:44 +0000
(19:41 +0000)
committer
Serge Guelton
<sguelton@redhat.com>
Thu, 14 Feb 2019 19:41:44 +0000
(19:41 +0000)
llvm-svn: 354055
llvm/include/llvm/ADT/Optional.h
patch
|
blob
|
history
diff --git
a/llvm/include/llvm/ADT/Optional.h
b/llvm/include/llvm/ADT/Optional.h
index
c628df9
..
f7d35c7
100644
(file)
--- a/
llvm/include/llvm/ADT/Optional.h
+++ b/
llvm/include/llvm/ADT/Optional.h
@@
-116,7
+116,9
@@
template <typename T> struct OptionalStorage<T, true> {
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));