close
vector<int> v{1,2,3,4,5,6,7,8,9} ;
int n = 3 ;
auto fun([n](int i){return i%n ==0;}) ;
auto t1 = std::chrono::high_resolution_clock::now();
int inum = count_if(v.begin(),v.end(),std::cref(fun)) ;
auto t2 = std::chrono::high_resolution_clock::now();
auto difference = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1);
std::cout << difference.count() << std::endl ;
cout << inum << endl ;
http://www.drdobbs.com/cpp/efficient-use-of-lambda-expressions-and/232500059
全站熱搜