Cluedo Solver v1.0
Cluedo game solver making deductions.
Loading...
Searching...
No Matches
Result.hpp File Reference

The file that defines the Result class and the TRY and MUST macros. More...

#include <cassert>
#include <optional>
#include <variant>

Go to the source code of this file.

Classes

class  Result< ValueType, ErrorType >
 A class that represents a result that can either be a value or an error. More...
 
class  Result< void, ErrorType >
 A specialization of the Result class for the case where the value is void. More...
 

Macros

#define TRY(expr)
 
#define MUST(expr)
 

Detailed Description

The file that defines the Result class and the TRY and MUST macros.

Macro Definition Documentation

◆ MUST

#define MUST ( expr)
Value:
({ \
auto _tmp = (expr); \
assert(_tmp.is_value()); \
_tmp.release_value(); \
})

A macro that is used to check the result of an expression that returns a Result object. If the result is an error, it will assert, otherwise it will return the value.

Template Parameters
exprThe expression that returns a Result object.

◆ TRY

#define TRY ( expr)
Value:
({ \
auto _tmp = (expr); \
if (_tmp.is_error()) \
return _tmp.release_error(); \
_tmp.release_value(); \
})

A macro that is used to check the result of an expression that returns a Result object. If the result is an error, it will return the error, otherwise it will return the value.

Template Parameters
exprThe expression that returns a Result object.