2010-11-06から1日間の記事一覧

lambdaさんの日常

#include <iostream> using namespace std; int main(){ auto lambda = []()->bool { static int i=0; cout << i++ << endl; if(i <= 20) return true; else return false; }; while( lambda() ); } 出力結果 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 便</iostream>…

trailing return type

#include <iostream> using namespace std; auto func()->int{ return 3; } int main(){ cout << func(); } 出力結果 3 ・・・オイコラ。絶対コレ、ラムダ式のついでに実装しただけだろ。 返り値の型を可変にしたいならtemplateでいいし、そもそもコレじゃ実現できない</iostream>…