SHA256
modify something
This commit is contained in:
@@ -4,37 +4,37 @@
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
namespace flog {
|
||||
namespace flog
|
||||
{
|
||||
template <typename T>
|
||||
class PushResult {
|
||||
class PushResult
|
||||
{
|
||||
public:
|
||||
_NODISCARD static PushResult success() noexcept { return PushResult(); }
|
||||
_NODISCARD static PushResult failWithValue(T value) noexcept {
|
||||
_NODISCARD static PushResult failWithValue(T value) noexcept
|
||||
{
|
||||
return PushResult(std::move(std::optional<T>(std::move(value))));
|
||||
}
|
||||
|
||||
_NODISCARD bool isSuccessful() const noexcept { return !m_value.has_value(); }
|
||||
_NODISCARD bool isFail() const noexcept { return m_value.has_value(); }
|
||||
|
||||
void getValueIfFail(const std::function<void(const T& value)> func) const {
|
||||
void getValueIfFail(const std::function<void(const T& value)> func) const
|
||||
{
|
||||
if (isFail()) {
|
||||
func(m_value.value());
|
||||
}
|
||||
}
|
||||
|
||||
_NODISCARD T getValue() const {
|
||||
return m_value.value();
|
||||
}
|
||||
_NODISCARD T getValue() const { return m_value.value(); }
|
||||
|
||||
PushResult(const PushResult &other) noexcept {
|
||||
m_value = other.m_value;
|
||||
}
|
||||
PushResult(const PushResult &other) noexcept { m_value = other.m_value; }
|
||||
|
||||
private:
|
||||
PushResult() noexcept = default;
|
||||
explicit PushResult(std::optional<T> value) noexcept : m_value(std::move(value)) {}
|
||||
|
||||
std::optional<T> m_value = std::nullopt;
|
||||
const std::optional<T> m_value = std::nullopt;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user