Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just anonymous function would make a huge difference. Presently, you have to use boost or create new classes (Yes, you need to write a class for any anonymous function! (See Effective Stl, item 46 for more details of why it is recommended)).

So, taken from: http://www2.research.att.com/~bs/C++0xFAQ.html#lambda

You could write something like:

  void f(vector<Record>& v)
  	{
  		vector<int> indices(v.size());
  		int count = 0;
  		fill(indices.begin(),indices.end(),[&count](){ return ++count; });
  
  		// sort indices in the order determined by the name field of the records:
  		std::sort(indices.begin(), indices.end(), [&](int a, int b) { return v[a].name<v[b].name; });
  		// ...
  	}


Welcome to ... what? 1970? 1960? How many decades ago did other languages have anonymous functions?


Lisp, 1958. Though technically they were invented in 1936 by Alonzo Church (in his Lambda Calculus).


There are function pointers in C and they are used to pass logic into C/C++ functions. They are not anonymous, and are more awkward to use than the new syntax, but they covered many use cases.


Exactly! Now it's time for the assembly language to get anonymous lambdas too :)


If only C++ was as useful as the odd bit of assembly programming.


I hope they at least beat Java to it.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: