Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no suitable user-defined conversion from "lambda []()->void" to "std::function<void ()>" existsC/C++(312) #13310

Open
mconti80 opened this issue Feb 25, 2025 · 0 comments

Comments

@mconti80
Copy link

I'm working in C++ on a MacBook Air M1. After updating to Sequoia 15.3.1, IDE error C/C++(312) appeared on an apparently correct code (it compiles with g++ with no warning.

Here is how it appeared on my project: the following call

inputManager.addKeyPress(0, 0, 0, 0, GLFW_KEY_W, [this]() {
    camera.move(-ds * camera.getUp());
});

on the following method

void addKeyPress(int ctrl, int shift, int alt, int super, int key, std::function<void()> f) {
    int keyCode = computeKey(ctrl, shift, alt, super, key);
    if (keyPressActions.find(keyCode) != keyPressActions.end()) {
        throw std::runtime_error("KeyPress action already exists for this combination.");
    }
    keyPressActions[keyCode] = f;
}

shows the error C/C++(312)

no suitable user-defined conversion from "lambda []()->void" to "std::function<void ()>" existsC/C++(312)` near the `[` of `[this]()`

The red wiggled line shows up under the first "[" of the last argument of method call.

I would appreciate any help.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant