aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/Optional.h
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-02-21 00:27:28 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-02-21 00:27:28 +0000
commit5c43245bf459c77077b607e1b55e6928cfbe464e (patch)
tree82fed71a9b20a0c1b252d28969f293179656996c /include/llvm/ADT/Optional.h
parent06ab2c828a5605abec36eb0d6749940fa6eb7391 (diff)
downloadexternal_llvm-5c43245bf459c77077b607e1b55e6928cfbe464e.zip
external_llvm-5c43245bf459c77077b607e1b55e6928cfbe464e.tar.gz
external_llvm-5c43245bf459c77077b607e1b55e6928cfbe464e.tar.bz2
Provide a "None" value for convenience when using Optional<T>()
This implementation of NoneType/None does have some holes but I haven't found one that doesn't - open to improvement. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/Optional.h')
-rw-r--r--include/llvm/ADT/Optional.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/llvm/ADT/Optional.h b/include/llvm/ADT/Optional.h
index 6c91a13..b0d09f6 100644
--- a/include/llvm/ADT/Optional.h
+++ b/include/llvm/ADT/Optional.h
@@ -16,6 +16,7 @@
#ifndef LLVM_ADT_OPTIONAL_H
#define LLVM_ADT_OPTIONAL_H
+#include "llvm/ADT/None.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/AlignOf.h"
#include <cassert>
@@ -31,6 +32,7 @@ class Optional {
AlignedCharArrayUnion<T> storage;
bool hasVal;
public:
+ Optional(NoneType) : hasVal(false) {}
explicit Optional() : hasVal(false) {}
Optional(const T &y) : hasVal(true) {
new (storage.buffer) T(y);