Created
March 14, 2012 11:28
-
-
Save faithandbrave/2035885 to your computer and use it in GitHub Desktop.
ignore lambda parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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