C++14 ã® Initialized lambda captures ã試ãã¦ã¿ã
Clang 3.4(svn) ã§ã¯æ¢ã«å®è£
ããã¦ããã®ã§è»½ã試ãã¦ã¿ã¾ããã
[ã½ã¼ã¹]
#include <iostream> int main(){ int x = 4; auto y = [&r = x, x = x + 1](){ r += 2; return x + 2; }; std::cout << "x = " << x << " y = " << y() << std::endl; std::cout << "x = " << x << " y = " << y() << std::endl; std::cout << "x = " << x << " y = " << y() << std::endl; return 0; }
[åºå]
x = 4 y = 7 x = 6 y = 7 x = 8 y = 7
ãã¼ãããæ
£ããã¾ã§ã«æéããããããã
ã©ãããå ´åã«æå¹çã«æ´»ç¨ã§ããã ãããã
[ã³ã³ãã¤ã©]
- clang++ (LLVM) 3.4 20131004(trunk)