Skip to content

Commit

Permalink
Emit anonymous functions as constexpr or mutable lambdas
Browse files Browse the repository at this point in the history
See comment thread for previous commit:
hsutter@4bd0c04
  • Loading branch information
hsutter committed Dec 3, 2023
1 parent bc82833 commit b9e73e0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4421,10 +4421,15 @@ class cppfront
emit(*n.parameters);
}

// For an anonymous function, make the emitted lambda 'mutable'
// For an anonymous function, the emitted lambda is 'constexpr' or 'mutable'
if (!n.my_decl->has_name())
{
printer.print_cpp2( " mutable", n.position() );
if (n.my_decl->is_constexpr) {
printer.print_cpp2( " constexpr", n.position() );
}
else {
printer.print_cpp2( " mutable", n.position() );
}
}

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

0 comments on commit b9e73e0

Please sign in to comment.