mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 17:32:49 +00:00
Add a T&& constructor to llvm::Optional.
This allows llvm::Optional to be used with movable-but-not-copyable types. While LLVM itself is still C++03, there's no reason why tools built on top of it can't use C++11 features. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166241 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
82c5180ed1
commit
9d9a6128fe
@ -16,8 +16,13 @@
|
||||
#ifndef LLVM_ADT_OPTIONAL
|
||||
#define LLVM_ADT_OPTIONAL
|
||||
|
||||
#include "LLVM/Support/Compiler.h"
|
||||
#include <cassert>
|
||||
|
||||
#if LLVM_USE_RVALUE_REFERENCES
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
namespace llvm {
|
||||
|
||||
template<typename T>
|
||||
@ -28,6 +33,10 @@ public:
|
||||
explicit Optional() : x(), hasVal(false) {}
|
||||
Optional(const T &y) : x(y), hasVal(true) {}
|
||||
|
||||
#if LLVM_USE_RVALUE_REFERENCES
|
||||
Optional(T &&y) : x(std::forward<T>(y)), hasVal(true) {}
|
||||
#endif
|
||||
|
||||
static inline Optional create(const T* y) {
|
||||
return y ? Optional(*y) : Optional();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user