From cc6be754f724fe6efdc6099da785100c3c825cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20E=2E=20Garc=C3=ADa?= Date: Tue, 7 Nov 2017 00:10:38 -0600 Subject: [PATCH] Remove deprecated Optional.h --- src/core/Optional.h | 93 --------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 src/core/Optional.h diff --git a/src/core/Optional.h b/src/core/Optional.h deleted file mode 100644 index fb800198a..000000000 --- a/src/core/Optional.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2017 KeePassXC Team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 or (at your option) - * version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef OPTIONAL_H -#define OPTIONAL_H - -/* - * This utility class is for providing basic support for an option type. - * It can be replaced by std::optional (C++17) or - * std::experimental::optional (C++11) when they become fully supported - * by all the compilers. - */ - -template -class Optional -{ -public: - - // None - Optional() : - m_hasValue(false), - m_value() - { }; - - // Some T - Optional(const T& value) : - m_hasValue(true), - m_value(value) - { }; - - // Copy - Optional(const Optional& other) : - m_hasValue(other.m_hasValue), - m_value(other.m_value) - { }; - - const Optional& operator=(const Optional& other) - { - m_hasValue = other.m_hasValue; - m_value = other.m_value; - return *this; - } - - bool operator==(const Optional& other) const - { - if(m_hasValue) - return other.m_hasValue && m_value == other.m_value; - else - return !other.m_hasValue; - } - - bool operator!=(const Optional& other) const - { - return !(*this == other); - } - - bool hasValue() const - { - return m_hasValue; - } - - T valueOr(const T& other) const - { - return m_hasValue ? m_value : other; - } - - Optional static makeOptional(const T& value) - { - return Optional(value); - } - - -private: - - bool m_hasValue; - T m_value; -}; - -#endif // OPTIONAL_H