Multiple std::variant visit with variadic templated helper
Following call would work:
int main() {
Possible<int> a = 16;
Possible<bool> b = true;
std::function<void(int, bool)> fun = [](int x, bool y) -> void {
std::cout << "All types set!" << std::endl;
};
ifAll(fun,
std::move(a),
std::move(b));
}
or switch your function signature to:
template <typename... Types>
void ifAll(std::function<void(Types...)> const& all, Possible<Types>&... possibles)
and then you can call it without std::move
:
int main() {
Possible<int> a = 16;
Possible<bool> b = true;
std::function<void(int, bool)> fun = [](int x, bool y) -> void {
std::cout << "All types set!" << std::endl;
};
ifAll(fun, a, b);
}