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

source code of lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/MyOptional.cpp