Closed
Description
.clang-format:
BasedOnStyle: Google
Here is the formatted code when lambda doesn't have constexpr/noexcept specifier:
#include <type_traits>
void very_long_function_name_yes_it_is_really_long(...);
void do_something(...);
int main() {
very_long_function_name_yes_it_is_really_long(
[](auto n)
-> std::enable_if_t<
std::is_arithmetic<decltype(n)>::value &&
!std::is_same<std::remove_cv_t<decltype(n)>, bool>::value> {
do_something(n * 2);
});
}
As expected trailing return arrow is indented 4 spaces after the lambda. But adding constexpr or noexcept specifier after lambda makes it 0 spaces:
#include <type_traits>
void very_long_function_name_yes_it_is_really_long(...);
void do_something(...);
int main() {
very_long_function_name_yes_it_is_really_long(
// also happens with constexpr specifier
[](auto n) noexcept
-> std::enable_if_t<
std::is_arithmetic<decltype(n)>::value &&
!std::is_same<std::remove_cv_t<decltype(n)>, bool>::value> {
do_something(n * 2);
});
}
Somewhat surprisingly, this issue doesn't happen when noexcept specifier with expression is used (e.g. noexcept(true)
).
clang-format version: 17.0.6
OS: EndeavourOS Linux, kernel 6.9.3-arch1-1