Skip to content

Instantly share code, notes, and snippets.

@yipo
Last active September 3, 2021 02:49
Show Gist options
  • Save yipo/c5cacecccaefe6dc6413a3961be792f9 to your computer and use it in GitHub Desktop.
Save yipo/c5cacecccaefe6dc6413a3961be792f9 to your computer and use it in GitHub Desktop.
Omit unused parameters of lambda.
#include <functional>
#include <string>
void test(std::function<int(const std::string & a, const std::string & b, const std::string & c)> func)
{
func({}, {}, {});
}
int main()
{
test([](const std::string & a, const std::string & b, const std::string & c)
{
return 0;
});
test([](auto, auto, auto)
{
return 0;
});
test([](auto...)
{
return 0;
});
test([](...)
{
return 0;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment