Skip to content

Instantly share code, notes, and snippets.

@faithandbrave
Created March 14, 2012 11:28
Show Gist options
  • Save faithandbrave/2035885 to your computer and use it in GitHub Desktop.
Save faithandbrave/2035885 to your computer and use it in GitHub Desktop.
ignore lambda parameter
#include <iostream>
#include <string>
struct ignore_param {
template <class... Args>
ignore_param(Args&&...) {}
};
template <class F>
void foo(F&& f)
{
std::string name = "Akira";
int age = 27;
std::string lang = "C++";
f(name, age, lang);
}
int main()
{
foo([](const std::string& name, int age, ignore_param) {
std::cout << name << ", " << age << std::endl;
});
}
/*
output:
Akira, 27
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment