I am trying to invoke the first parameter in a tuple with the second one as a parameter, but can't figure out how to do it.
Example:
#include <tuple>
#include <functional>
struct S {
void operator()(int) {}
};
int main() {
S s;
auto t = std::make_tuple(s, 3);
std::invoke(s, 3);
// std::apply(std::invoke, t); // This is what I want to do
// std::apply(std::invoke<S, int>, t); // I would settle for this "Good Enough"
}
but the code above doesn't compile, and the error is very unhelpful (to me):
error: no matching function for call to '__invoke(void (&)(S&&, int&&), std::__tuple_element_t<0, std::tuple<S, int> >&, std::__tuple_element_t<1, std::tuple<S, int> >&)'
(this is from the "good enough" attempt)
Anyone know how to do this, or if it can't be done?