Finally I got too tired of typing the arguments of iroha::expected::Result::match functions. Looking at its signature and docstring comment, I saw that the first matcher is for the value case, and the second - for the error. But this deduction did not happen, because both were just passed to some sort of apply_visitor, which does not care of visitors' positions. So I made a change before the visitor application, forcing the first visitor to accept value type, and the second - error type.
just use auto type in matchers. don't forget about matched Result const- and ref-qualifiers: for example, if it is an rvalue (most common case), use either auto && or const auto & argument type in your machers.
Signed-off-by: Mikhail Boldyrev miboldyrev@gmail.com
Description of the Change
Finally I got too tired of typing the arguments of
iroha::expected::Result::match
functions. Looking at its signature and docstring comment, I saw that the first matcher is for the value case, and the second - for the error. But this deduction did not happen, because both were just passed to some sort ofapply_visitor
, which does not care of visitors' positions. So I made a change before the visitor application, forcing the first visitor to accept value type, and the second - error type.Benefits
saves some hair on your head. just see this:
Possible Drawbacks
Usage Examples or Tests [optional]
just use
auto
type in matchers. don't forget about matchedResult
const- and ref-qualifiers: for example, if it is an rvalue (most common case), use eitherauto &&
orconst auto &
argument type in your machers.Alternate Designs [optional]