Skip to content

modernize-use-trailing-return-type might show invalid type in fix-it hint for lamdba with iterator #144509

Open
@firewave

Description

@firewave
#include <algorithm>
#include <vector>

void f()
{
    auto it = [](const std::vector<int>& v) {
        return v.cbegin();
    };
}
<source>:6:15: warning: use a trailing return type for this lambda [modernize-use-trailing-return-type]
    6 |     auto it = [](const std::vector<int>& v) {
      |               ^
      |                                             -> const_iterator

https://godbolt.org/z/zzYMa4o5r

It should be suggesting std::vector<int>::const_iterator.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions