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

Strange behavior of hana::partial #528

Open
fdevinc opened this issue Mar 7, 2024 · 0 comments
Open

Strange behavior of hana::partial #528

fdevinc opened this issue Mar 7, 2024 · 0 comments

Comments

@fdevinc
Copy link

fdevinc commented Mar 7, 2024

Hello, and thank you for the excellent library! I found a strange behavior using hana::partial as shown in the following snippet:

auto lambda = [](int& i) {
    std::cout << i++ << " ";
    std::cout << i << std::endl;
};
const int j  = 0;
auto partial = hana::partial(lambda, j);
partial();

The above will print 0 1 and change the value of the constant variable i. Is this behavior expected? If I do not store the output of hana::partial, then the code does not compile as desired:

auto lambda = [](int& i) {
    std::cout << i++ << " ";
    std::cout << i << std::endl;
};
const int j  = 0;
hana::partial(lambda, j)();    // <= Error!
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