19 template <
typename TError>
36 return e1 +
" AND " + e2;
43 template <
typename TError>
66 template <typename T, typename = std::enable_if_t<std::is_constructible<TError, T>::value>>
76 INLINE explicit operator bool()
const {
97 return (!e && !other.e) || (e == other.e);
105 stream << outcome.
error();
146 template <
typename T0,
typename... TArgs>
149 printArgs(ss, std::forward<TArgs>(args)...);
156 template <
typename... TArgs>
158 std::stringstream ss;
167 template <
typename... TArgs>
172 std::stringstream ss;
#define SPH_ASSERT(x,...)
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
Wrapper of type value of which may or may not be present.
BasicOutcome< std::string > Outcome
Alias for string error message.
INLINE Outcome makeOutcome(const bool condition, TArgs &&... args)
Constructs outcome object given the condition.
const SuccessTag SUCCESS
Global constant for successful outcome.
INLINE Outcome makeFailed(TArgs &&... args)
Constructs failed object with error message.
Expected-like class that does not contain any value.
INLINE BasicOutcome(T &&error)
Constructs object given error message.
friend BasicOutcome operator||(const BasicOutcome &o1, const BasicOutcome &o2)
Logical 'or' operator, returning SUCCESS if either of the values is a SUCCESS.
INLINE const TError & error() const
Returns the error message.
friend std::ostream & operator<<(std::ostream &stream, const BasicOutcome &outcome)
Prints "success" or error message into the output stream.
INLINE BasicOutcome(const bool value)
Constructs object from boolean result.
bool operator==(const BasicOutcome &other) const
Compares two outcomes.
INLINE BasicOutcome(SuccessTag)
Constructs object with success (no error)
INLINE bool success() const
Checks whether the object contains success, i.e. no error is stored.
friend BasicOutcome operator&&(const BasicOutcome &o1, const BasicOutcome &o2)
Logical 'and' operator, returning SUCCESS if both values are SUCCESS.
INLINE bool operator!() const
Inversion operator.
INLINE BasicOutcome(FailTag)
Constructs object with defautl error message.
INLINE Type & value()
Returns the reference to the stored value.
void emplace(TArgs &&... args)
Constructs the uninitialized object from a list of arguments.
INLINE void printArgs(std::stringstream &)
Overload of std::swap for Sph::Array.
static INLINE std::string defaultError()
static INLINE std::string concatenate(const std::string &e1, const std::string &e2)
Utility functions used within BasicOutcome.
static INLINE TError concatenate(const TError &e1, const TError &e2)
Concatenated two error messages.
static INLINE TError defaultError()
Helper function returning default error message.