From ba879a882e031d7b8503f78fe41d1210000c96ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Fri, 16 Mar 2018 00:53:47 +0100 Subject: Use std::optional instead of OptionalBool --- src/utils/optional_bool.hpp | 48 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'src/utils/optional_bool.hpp') diff --git a/src/utils/optional_bool.hpp b/src/utils/optional_bool.hpp index 867aca2..c652ed3 100644 --- a/src/utils/optional_bool.hpp +++ b/src/utils/optional_bool.hpp @@ -1,37 +1,21 @@ #pragma once +#include + #include -struct OptionalBool +namespace std { - OptionalBool() = default; - - OptionalBool(bool value): - is_set(true), value(value) {} - - void set_value(bool value) - { - this->is_set = true; - this->value = value; - } - - void unset() - { - this->is_set = false; - } - - std::string to_string() const - { - if (this->is_set == false) - return "unset"; - else if (this->value) - return "true"; - else - return "false"; - } - - bool is_set{false}; - bool value{false}; -}; - -std::ostream& operator<<(std::ostream& os, const OptionalBool& o); +inline +std::string to_string(const std::optional b) +{ + if (!b) + return "unset"; + else if (*b) + return "true"; + else + return "false"; +} +} + +std::ostream& operator<<(std::ostream& os, const std::optional& o); -- cgit v1.2.3