refactor(result): add print operator to result

Fixes #6
This commit is contained in:
2026-06-03 16:06:59 +02:00
parent 1b9514c49c
commit ab6b65a70e
2 changed files with 23 additions and 0 deletions
+12
View File
@@ -2,6 +2,7 @@
#define FURLANG_RESULT_HPP
#include <exception>
#include <ostream>
#include <utility>
namespace furlang {
@@ -215,6 +216,17 @@ public:
*/
bool operator!=(const value_type& rhs) const { return !this->operator==(rhs); }
/**
* @brief Prints a result to an output stream.
*
* @param os Output stream.
* @param result Result to print.
* @return The output stream.
*/
friend std::ostream& operator<<(std::ostream& os, const result& result) {
return result.has_value() ? os << result.value() : os << result.error();
}
/**
* @brief Returns a reference to value.
*