Skip to content

Commit edae0e0

Browse files
committed
🚸 Guard all call options in msg::call_with_message
Problem: - Although the final `if constexpr` branch in `call_with_message` may not be taken, it can still cause a substitution failure in some cases. Solution: - Guard the last call option in `call_with_message`, and provide a hard error if none of the options succeeds. Note: - An example of such a substitution failure may occur in a predicate matcher whose predicate fails to have a `-> bool` trailing return type, and in forming the substitution the compiler tries to look at `decltype(pred(msg))` which instantiates the ill-formed function body.
1 parent 56ed298 commit edae0e0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

include/msg/message.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,16 @@ call_with_message(F &&f, S &&s, Args &&...args) -> decltype(auto) {
700700
}) {
701701
return std::forward<F>(f)(typename Msg::view_t{std::forward<S>(s)},
702702
std::forward<Args>(args)...);
703-
} else {
703+
} else if constexpr (requires {
704+
std::forward<F>(f)(
705+
typename Msg::owner_t{std::forward<S>(s)},
706+
std::forward<Args>(args)...);
707+
}) {
704708
return std::forward<F>(f)(typename Msg::owner_t{std::forward<S>(s)},
705709
std::forward<Args>(args)...);
710+
} else {
711+
static_assert(stdx::always_false_v<Msg, F, S>,
712+
"No call option for call_with_message");
706713
}
707714
}
708715

0 commit comments

Comments
 (0)