diff options
author | pommicket <pommicket@gmail.com> | 2022-12-27 00:16:35 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-27 00:16:35 -0500 |
commit | 85ee81b8ae972d17f0e3dc78657077924c047ada (patch) | |
tree | c786708c0e3b4d0340e712d01eb0160145e5af38 /test/test.cpp | |
parent | 9a5cad47fe6a8b84892f62e110ca887c95df5eff (diff) |
added workspaceFolders support
but broke non-workspaceFolders support
Diffstat (limited to 'test/test.cpp')
-rw-r--r-- | test/test.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 0000000..e373bff --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,62 @@ +#include <iostream> +char const *s = R"( +Lorem ipsum dolor sit amet. +It was the age of reason. +It was the age of foolishness. +do { + class x; +} while (0.1238712e+12 != CHAR_MAX); +)"; +using std::cout; + +template<typename T> +class Option { +public: + Option<T>() { + exists = false; + } + Option<T>(T const &t) { + set(t); + } + void set(T const &t) { + exists = true; + x = t; + } + void clear() { + exists = false; + } + T *get() { + if (exists) + return &x; + else + return nullptr; + } + T const *get() const { + if (exists) + return &x; + else + return nullptr; + } +private: + bool exists; + T x; +}; + +template<typename T> +void print_option(Option<T> const &o) { + T const *ptr = o.get(); + if (ptr) + cout << *ptr << "\n"; + else + cout << "None\n"; +} + +int main() { + Option<int> o(7); + print_option(o); + o.clear(); + print_option(o); + o.set(133); + print_option(o); + return 0; +} |