Lines Matching defs:Optional

1 //===-- Optional.h - Simple variant for passing optional values ---*- C++ -*-=//
10 // This file provides Optional, a template class modeled in the spirit of
28 class Optional {
32 Optional(NoneType) : hasVal(false) {}
33 explicit Optional() : hasVal(false) {}
34 Optional(const T &y) : hasVal(true) {
37 Optional(const Optional &O) : hasVal(O.hasVal) {
42 Optional(T &&y) : hasVal(true) {
45 Optional(Optional<T> &&O) : hasVal(O) {
51 Optional &operator=(T &&y) {
60 Optional &operator=(Optional &&O) {
70 static inline Optional create(const T* y) {
71 return y ? Optional(*y) : Optional();
74 // FIXME: these assignments (& the equivalent const T&/const Optional& ctors)
79 Optional &operator=(const T &y) {
89 Optional &operator=(const Optional &O) {
104 ~Optional() {
127 template <typename T> struct isPodLike<Optional<T> > {
128 // An Optional<T> is pod-like if T is.
132 /// \brief Poison comparison between two \c Optional objects. Clients needs to
133 /// explicitly compare the underlying values and account for empty \c Optional
139 void operator==(const Optional<T> &X, const Optional<U> &Y);
141 /// \brief Poison comparison between two \c Optional objects. Clients needs to
142 /// explicitly compare the underlying values and account for empty \c Optional
148 void operator!=(const Optional<T> &X, const Optional<U> &Y);
150 /// \brief Poison comparison between two \c Optional objects. Clients needs to
151 /// explicitly compare the underlying values and account for empty \c Optional
157 void operator<(const Optional<T> &X, const Optional<U> &Y);
159 /// \brief Poison comparison between two \c Optional objects. Clients needs to
160 /// explicitly compare the underlying values and account for empty \c Optional
166 void operator<=(const Optional<T> &X, const Optional<U> &Y);
168 /// \brief Poison comparison between two \c Optional objects. Clients needs to
169 /// explicitly compare the underlying values and account for empty \c Optional
175 void operator>=(const Optional<T> &X, const Optional<U> &Y);
177 /// \brief Poison comparison between two \c Optional objects. Clients needs to
178 /// explicitly compare the underlying values and account for empty \c Optional
184 void operator>(const Optional<T> &X, const Optional<U> &Y);