Skip to content

Commit

Permalink
Merge pull request #132 from chaoticgd/really_tiny_refactor
Browse files Browse the repository at this point in the history
Some really minor changes in util.h
  • Loading branch information
chaoticgd authored Oct 29, 2023
2 parents fa7a5e7 + d6fab96 commit c454b7d
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ccc/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ class Result {
m_error = rhs.m_error;
}

static Result<Value> success(Value value) {
Result<Value> result;
result.m_value = std::move(value);
return result;
}

static Result<Value> failure(Error* error) {
Result<Value> result;
result.m_error = error;
Expand Down Expand Up @@ -129,15 +123,14 @@ class Result<void> : public Result<int> {
public:
Result() : Result<int>(0) {}

template <typename Dummy>
Result(const Result<Dummy>& rhs) {
template <typename OtherValue>
Result(const Result<OtherValue>& rhs) {
CCC_ASSERT(rhs.m_error != nullptr);
m_error = rhs.m_error;
}
};

struct ResultDummyValue {};
#define CCC_FAILURE(...) ccc::Result<ccc::ResultDummyValue>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))
#define CCC_FAILURE(...) ccc::Result<int>::failure(ccc::format_error(__FILE__, __LINE__, __VA_ARGS__))
#define CCC_RETURN_IF_ERROR(result) if(!(result).success()) return (result);
#define CCC_EXIT_IF_ERROR(result) \
if(!(result).success()) { \
Expand Down

0 comments on commit c454b7d

Please sign in to comment.