Skip to content

Strange behavior of hana::partial #528

Description

@fdevinc

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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