Skip to content

Commit 3fd61b3

Browse files
committed
C++11 lambda expressions support
Updated the C code generator to generate C++11 lambda expressions for DSL-level lambda expressions
1 parent 2f7c0d1 commit 3fd61b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/common/Functions.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ trait CGenTupledFunctions extends CGenFunctions with GenericGenUnboxedTupleAcces
376376

377377
override def emitNode(sym: Sym[Any], rhs: Def[Any]) = rhs match {
378378
case Lambda(fun, UnboxedTuple(xs), y) =>
379-
stream.println(remap(y.tp)+" "+quote(sym)+"("+xs.map(s=>remap(s.tp)+" "+quote(s)).mkString(",")+") {")
379+
stream.println("auto "+quote(sym)+" = [&]("+xs.map(s=>remap(s.tp)+" "+quote(s)).mkString(",")+") {")
380380
emitBlock(y)
381381
val z = getBlockResult(y)
382382
if (remap(z.tp) != "void")
383383
stream.println("return " + quote(z) + ";")
384-
stream.println("}")
384+
stream.println("};")
385385
case Apply(fun, UnboxedTuple(args)) =>
386386
emitValDef(sym, quote(fun) + args.map(quote).mkString("(", ",", ")"))
387387
case _ => super.emitNode(sym,rhs)

0 commit comments

Comments
 (0)