Result-CPP is a C++ library that provides a Result<T, E>
type, which can be used to return and propagate errors. It's inspired by Rust's std::Result
type.
+
+
Result-CPP is a C++ library that provides a Result<T, E>
type, which can be used to return and propagate errors. It's inspired by Rust's std::Result
type.
Features
@@ -105,9 +106,9 @@
if (b == 0) {
-
+ return res::Err(std::string(
"Division by zero"));
} else {
-
+
}
}
@@ -120,6 +121,8 @@
std::cout << "Error: " << result.unwrap_err() << '\n';
}
}
+Err object represents an unsuccessful outcome and can be converted to a Result.
Definition: result.h:73
+Ok object represents a successful outcome and can be converted to a Result.
Definition: result.h:48
Result is a type that represents either success or failure.
Definition: result.h:25
result-cpp is a C++ library that provides a Result<T, E> type, which can be used to return and propag...