Open weidonglian opened 3 years ago
Sorry that I'm answering late. I don't get notified for arbitrary issues in this reposity unless I get notified (which is explicitly said in the issue template you deleted).
I'm glad that you like the library. I think the best solution is a trait that can be specialized by the user for specific types:
namespace cti {
template<typename T>
struct exception_trait {
static bool is_exception(T const& value) noexcept {
return bool(value);
}
// ... Possible additional specializations
};
}
I'm open for accepting a pull request that implements this specialization.
First I really enjoy this great library and really nice work! It does solve the callback hell with asio. Since we have no coroutine available whatsoever, continuable probably is now the best we can achieve.
In the callback's excetion_t has to implement operator bool which is not so portable and could be confusing,e.g. absl::Status or our own Error. in absl::Status, it prefers to check by absl::Status::ok(), however, bool(exception) should mean a non-zero error code, i.e. not ok, which we do not want to add an operator bool for absl::Status or our own error type.
I am suggesting if we could provide a functor to replace
bool(exception)
, i.e. something similar to std::hash, then we could implement it for the given error type.How about template specialization for a different type of exception_t? we can default to std::error_condtion. Then we got a chance to specialize an exception_t on our own, e.g. make_error(e). It would look like: