C++14 ã® Generic Lambdas ã§å¯å¤é·å¼æ°
Clang 3.4(svn) ã§è©¦ãã¦ã¿ã¾ããã
[ã½ã¼ã¹]
#include <iostream> #include <string> int main(){ auto sum = [](auto x, auto&&... args){ for(auto&& n : {args...}){ x += n; } return x; }; std::cout << sum(1, 2, 3) << std::endl; std::cout << sum(std::string("homu"), "mami", "mado") << std::endl; return 0; }
[åºå]
6 homumamimado
åãã¦ããããã§ããã
ã©ã ãã®æ§æä¸ãå帰ã¯ã§ããªããã§ããããããã¨ä½¿ãããã§ãã
[ã³ã³ãã¤ã©]
- clang++ (LLVM) 3.4 20131004(trunk)