finish log_manager.cpp

This commit is contained in:
CupWater
2026-08-17 18:27:39 +08:00
parent e4d834e4a9
commit 1313cab93e
4 changed files with 71 additions and 16 deletions
+24 -7
View File
@@ -2,22 +2,39 @@
#define FEATHERLOG_PUSH_RESULT_HPP
#include <optional>
#include <functional>
namespace flog {
template <typename T>
class PushResult {
public:
static PushResult getVoid() {
return PushResult(3);
_NODISCARD static PushResult success() noexcept { return PushResult(); }
_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 {
if (isFail()) {
func(m_value.value());
}
}
_NODISCARD T getValue() const {
return m_value.value();
}
PushResult(const PushResult &other) noexcept {
m_value = other.m_value;
}
private:
explicit PushResult(std::optional<T> value) : m_value(value) {
std::optional<T> bad;
std::map<int, std::optional<T>> mp;
}
PushResult() noexcept = default;
explicit PushResult(std::optional<T> value) noexcept : m_value(std::move(value)) {}
std::optional<T> m_value;
std::optional<T> m_value = std::nullopt;
};
}