xref: /llvm-project/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp (revision fffe8c668461e73055182f229765cb7de908e295)
1 // A bare-bones llvm::Optional reimplementation.
2 
3 template <typename T> struct MyOptionalStorage {
4   MyOptionalStorage(T val) : value(val), hasVal(true) {}
5   MyOptionalStorage() {}
6   T value;
7   bool hasVal = false;
8 };
9 
10 template <typename T> struct MyOptional {
11   MyOptionalStorage<T> Storage;
12   MyOptional(T val) : Storage(val) {}
13   MyOptional() {}
14   T &operator*() { return Storage.value; }
15 };
16 
17 void stop() {}
18 
19 int main(int argc, char **argv) {
20   MyOptional<int> x, y = 42;
21   stop(); // break here
22   return *y;
23 }
24