Skip to content

Commit b9e73e0

Browse files
committed
Emit anonymous functions as constexpr or mutable lambdas
See comment thread for previous commit: 4bd0c04
1 parent bc82833 commit b9e73e0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

source/to_cpp1.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -4421,10 +4421,15 @@ class cppfront
44214421
emit(*n.parameters);
44224422
}
44234423

4424-
// For an anonymous function, make the emitted lambda 'mutable'
4424+
// For an anonymous function, the emitted lambda is 'constexpr' or 'mutable'
44254425
if (!n.my_decl->has_name())
44264426
{
4427-
printer.print_cpp2( " mutable", n.position() );
4427+
if (n.my_decl->is_constexpr) {
4428+
printer.print_cpp2( " constexpr", n.position() );
4429+
}
4430+
else {
4431+
printer.print_cpp2( " mutable", n.position() );
4432+
}
44284433
}
44294434

44304435
// For now, adding implicit noexcept only for move/swap/dtor functions

0 commit comments

Comments
 (0)