6

Possible Duplicate:
C++0x and the Lack of Polymorphic Lambdas - Why?

C++0x lambda expressions support return type inference to some point. Why aren't argument types determined automatically, too?

Eg, why can't I write:

void somefunc(const std::vector<int>& v) 
{
    std::sort(v.begin(), v.end(), [](x, y) { return x < y; });
}

It would seem that the compiler should be able to figure out that x and y are of type int.

Community
  • 1
  • 1
Daniel Gehriger
  • 7,339
  • 2
  • 34
  • 55
  • 6
    Such functionality is called *polymorphism*, the search term for you is *polymorphic lambda's*. It's a [duplicate](http://stackoverflow.com/questions/4643039/c0x-and-the-lack-of-polymorphic-lambdas-why). (And yes, it'd be *really* nice to have, but we don't. Sucks.) – GManNickG Jan 26 '11 at 10:45
  • 1
    Thanks a lot. I was searching through SO, but didn't know what to look for. – Daniel Gehriger Jan 26 '11 at 12:09

0 Answers0