diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
commit | fd035e6496665b1f1197868e21cb0a4594e8db6e (patch) | |
tree | 53010172e19c77ea447bcd89e117cda052ab52e0 /include/clang/Analysis/Support/Optional.h | |
parent | 2fce988e86bc01829142e4362d4eff1af0925147 (diff) | |
download | FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.zip FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.tar.gz |
Update clang to r96341.
Diffstat (limited to 'include/clang/Analysis/Support/Optional.h')
-rw-r--r-- | include/clang/Analysis/Support/Optional.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/include/clang/Analysis/Support/Optional.h b/include/clang/Analysis/Support/Optional.h index 40f38be..a4e6d51 100644 --- a/include/clang/Analysis/Support/Optional.h +++ b/include/clang/Analysis/Support/Optional.h @@ -20,19 +20,27 @@ namespace clang { template<typename T> class Optional { - const T x; + T x; unsigned hasVal : 1; public: - explicit Optional() : hasVal(false) {} + explicit Optional() : x(), hasVal(false) {} Optional(const T &y) : x(y), hasVal(true) {} static inline Optional create(const T* y) { return y ? Optional(*y) : Optional(); } + Optional &operator=(const T &y) { + x = y; + hasVal = true; + return *this; + } + const T* getPointer() const { assert(hasVal); return &x; } + const T& getValue() const { assert(hasVal); return x; } operator bool() const { return hasVal; } + bool hasValue() const { return hasVal; } const T* operator->() const { return getPointer(); } const T& operator*() const { assert(hasVal); return x; } }; |