c++ - C++11 and the lack of polymorphic lambdas - why? -
i've been reviewing draft version of c++11 standard. section on lambdas, , confused reasoning not introducing polymorphic lambdas.
for example, amongst 100001 ways polymorphic lambdas used, had hoped use code such following:
template<typename container> void foo(container c) { for_each(c.begin(), c.end(), [](t& t) { ++t; }); }
what reasons:
was committee ran out of time?
that polymorphic lambdas hard implement?
or perhaps seen not being needed ptb?
note: please remember example above not one, , provided guide types of code. answers solely concentrate on providing workaround above piece of code not considered valid!
related sources:
- lambda expressions , closures c++ (document number n1968=06-0038)
- can lambda functions templated?
the reason don't have polymorphic lambdas explained pretty in this posting.
it has concepts feature pulled c++11: essentially, polymorphic lambdas ordinary, unconstrained function templates , didn't know how typecheck concept-constrained template used unconstrained template. however, solving problem turns out easy shown here(dead link), don't think there's obstacle remaining.
the link cpp-next dead; relevant info can found here
Comments
Post a Comment