Revert "Use std::optional<bool> instead of OptionalBool"
This reverts commit ba879a882e.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include <utils/optional_bool.hpp>
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const std::optional<bool>& o)
|
||||
std::ostream& operator<<(std::ostream& os, const OptionalBool& o)
|
||||
{
|
||||
os << std::to_string(o);
|
||||
os << o.to_string();
|
||||
return os;
|
||||
}
|
||||
|
||||
+31
-15
@@ -1,21 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace std
|
||||
struct OptionalBool
|
||||
{
|
||||
inline
|
||||
std::string to_string(const std::optional<bool> b)
|
||||
{
|
||||
if (!b)
|
||||
return "unset";
|
||||
else if (*b)
|
||||
return "true";
|
||||
else
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
OptionalBool() = default;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const std::optional<bool>& o);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user