feat update
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#include "sled/filesystem/path.h"
|
||||
#include "sled/filesystem/temporary_file.h"
|
||||
|
||||
// lang
|
||||
#include "lang/attributes.h"
|
||||
|
||||
// log
|
||||
#include "sled/log/log.h"
|
||||
|
||||
|
@@ -49,9 +49,7 @@ class ErrorInfo {
|
||||
public:
|
||||
ErrorInfo() = default;
|
||||
|
||||
explicit ErrorInfo(std::string reason,
|
||||
std::string domain,
|
||||
std::unordered_map<std::string, std::string> metadata)
|
||||
explicit ErrorInfo(std::string reason, std::string domain, std::unordered_map<std::string, std::string> metadata)
|
||||
: reason_(std::move(reason)),
|
||||
domain_(std::move(domain)),
|
||||
metadata_(std::move(metadata))
|
||||
@@ -61,18 +59,13 @@ public:
|
||||
|
||||
std::string const &domain() const { return domain_; }
|
||||
|
||||
std::unordered_map<std::string, std::string> const &metadata() const
|
||||
{
|
||||
return metadata_;
|
||||
}
|
||||
std::unordered_map<std::string, std::string> const &metadata() const { return metadata_; }
|
||||
|
||||
friend bool operator==(ErrorInfo const &, ErrorInfo const &);
|
||||
friend bool operator!=(ErrorInfo const &, ErrorInfo const &);
|
||||
|
||||
private:
|
||||
friend void internal::AddMetadata(ErrorInfo &,
|
||||
std::string const &key,
|
||||
std::string value);
|
||||
friend void internal::AddMetadata(ErrorInfo &, std::string const &key, std::string value);
|
||||
std::string reason_;
|
||||
std::string domain_;
|
||||
std::unordered_map<std::string, std::string> metadata_;
|
||||
|
@@ -17,8 +17,7 @@ namespace sled {
|
||||
template<typename T>
|
||||
class StatusOr final {
|
||||
public:
|
||||
static_assert(!std::is_reference<T>::value,
|
||||
"StatusOr<T> requires T to **not** be a reference type");
|
||||
static_assert(!std::is_reference<T>::value, "StatusOr<T> requires T to **not** be a reference type");
|
||||
using value_type = T;
|
||||
|
||||
StatusOr() : StatusOr(MakeDefaultStatus()) {}
|
||||
@@ -26,9 +25,7 @@ public:
|
||||
StatusOr(StatusOr const &) = default;
|
||||
StatusOr &operator=(StatusOr const &) = default;
|
||||
|
||||
StatusOr(StatusOr &&other)
|
||||
: status_(std::move(other.status_)),
|
||||
value_(std::move(other.value_))
|
||||
StatusOr(StatusOr &&other) : status_(std::move(other.status_)), value_(std::move(other.value_))
|
||||
{
|
||||
other.status_ = MakeDefaultStatus();
|
||||
}
|
||||
@@ -43,10 +40,7 @@ public:
|
||||
|
||||
StatusOr(Status rhs) : status_(std::move(rhs))
|
||||
{
|
||||
if (status_.ok()) {
|
||||
throw std::invalid_argument(
|
||||
"Status::OK is not a valid argument to StatusOr<T>");
|
||||
}
|
||||
if (status_.ok()) { throw std::invalid_argument("Status::OK is not a valid argument to StatusOr<T>"); }
|
||||
}
|
||||
|
||||
StatusOr &operator=(Status status)
|
||||
@@ -57,9 +51,7 @@ public:
|
||||
|
||||
template<typename U = T,
|
||||
/// @code implementation detail
|
||||
typename std::enable_if<
|
||||
!std::is_same<StatusOr, typename std::decay<U>::type>::value,
|
||||
int>::type = 0
|
||||
typename std::enable_if<!std::is_same<StatusOr, typename std::decay<U>::type>::value, int>::type = 0
|
||||
/// @code end
|
||||
>
|
||||
StatusOr &operator=(U &&rhs)
|
||||
@@ -138,10 +130,7 @@ public:
|
||||
Status &&status() && { return std::move(status_); }
|
||||
|
||||
private:
|
||||
static Status MakeDefaultStatus()
|
||||
{
|
||||
return Status{StatusCode::kUnknown, "default"};
|
||||
}
|
||||
static Status MakeDefaultStatus() { return Status{StatusCode::kUnknown, "default"}; }
|
||||
|
||||
void CheckHasValue() const &
|
||||
{
|
||||
|
Reference in New Issue
Block a user