Consider this simple example code:
#include
#include
void f(bool _switch) {
std::cout << \"Nothing really\" &l
One more option to Vaughn Cato's answer:
template
void f(F _f) {
std::cout << "Nothing really, too: " << _f(3) << std::endl;
}
Now the second overload is a template, so it is chosen for a lambda (or anything), and the first is chosen for bool. So calling f is no more complex than needed.
But, one problem with that is if you want to add more overloads, and another is that the first overload will only be called if there is an exact match to bool.