gmock: improve SFINAE for actions involving arguments.

Avoid instantiating functions like std::get<index> for an out of range index
when doing SFINAE on the invocability of the action itself.

PiperOrigin-RevId: 439415110
Change-Id: Ifc20285a6d526c34830870cd1910c2b2b92e1e81
This commit is contained in:
Abseil Team
2022-04-04 14:38:08 -07:00
committed by Copybara-Service
parent 3ffa237f0e
commit 137f67e91f
2 changed files with 4 additions and 2 deletions

View File

@@ -600,7 +600,8 @@ auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) {
template <std::size_t index, typename... Params>
struct InvokeArgumentAction {
template <typename... Args>
template <typename... Args,
typename = typename std::enable_if<(index < sizeof...(Args))>::type>
auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument(
std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)),
std::declval<const Params&>()...)) {