Skip to content

Function 测试编译报错 #6

Open
@fengchen321

Description

@fengchen321

gcc13.1 -std=c++20

部分报错信息如下: https://godbolt.org/z/KzGoGbdvK
error: no matching function for call to 'forward(main()::<lambda(int)>&)'
29 | explicit _FuncImpl(std::in_place_t, _CArgs &&...__args) : _M_f(std::forward(__args)...) {}

GPT:std::make_unique 尝试调用 _FuncImpl 的构造函数时,传递的参数类型不匹配导致的。
确保 _FuncImpl 的构造函数能够正确处理函数指针的引用。通过添加一个额外的构造函数来处理。
能编译通过的代码:https://godbolt.org/z/h4KMKoMYc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions