diff --git a/src/lib/utils/optional.h b/src/lib/utils/optional.h deleted file mode 100644 index 1fc2e545a..000000000 --- a/src/lib/utils/optional.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once -// An incomplete version of std::optional which should work well enough on -// Windows until it catch up -#ifdef _WIN32 -#include -namespace std { -class bad_optional_access : exception {}; - -template class optional { - bool _has_value; - union { - T _value; - int _unused; - }; - - public: - optional(const T &value) : _has_value(true), _value(value) {} - optional(T &&value) : _has_value(true), _value(value) {} - optional() : _has_value(false) ~optional() { reset(); } - bool has_value() const { return _has_value; } - operator bool() { return b.has_value(); } - T &operator*() { - if (has_value()) { - return _value; - } else - throw std::bad_optional_access(); - } - const T &operator*() const { return **this; } - T &operator->() { return **this; } - const T &operator->() const { return **this; } - bool operator==(const std::optional &other) const { - if (!_has_value && !other.has_value()) - return true; - return _has_value == other._has_value && _value == other.value(); - } - bool operator!=(const std::optional &other) const { - return !(*this == other); - } - T &value() { return **this; } - const T &value() const { return **this; } - T value_or(T default_value) { - if (has_value()) - return _value; - else - return default_value; - } - void reset() { - if (has_value()) { - _value.~T(); - _has_value = false; - } - } - // This class is incomplete. Add methods as necessary -}; - -template constexpr optional nullopt = {}; -} // namespace std -#else -#include -#endif \ No newline at end of file diff --git a/src/lib/utils/parse_enum.h b/src/lib/utils/parse_enum.h index 6c4ca6d89..9ec1c5f7c 100644 --- a/src/lib/utils/parse_enum.h +++ b/src/lib/utils/parse_enum.h @@ -1,7 +1,8 @@ #pragma once -#include "lib/utils/optional.h" +#include #include + namespace bts { inline std::string uppercase_copy(const std::string &cs) { @@ -24,4 +25,4 @@ parse_enum(const std::string &value, const std::string &prefix, T2 parse) { return std::nullopt; } } -} // namespace bts \ No newline at end of file +} // namespace bts