Dobiasd / FunctionalPlus

Functional Programming Library for C++. Write concise and readable C++ code.
http://www.editgym.com/fplus-api-search/
Boost Software License 1.0
2.07k stars 168 forks source link

fwd bind count for `just_with_default` #287

Closed tom91136 closed 7 months ago

tom91136 commented 7 months ago

I think the the fwd version of just_with_default may be requiring a wrong bind count, because the following fails to compile:

    auto o = fplus::maybe<int>(1);
    auto p = fwd::apply(
        o,
        fwd::and_then_maybe([](auto x) { return x > 0 ? fplus::just(1) : fplus::nothing<int>(); }),
        fwd::lift_maybe([](auto x) { return x * 2; }),
        fwd::just_with_default(42)
    );

Setting fwd bind count: 1 for the function and regenerating fixes the issue.

Dobiasd commented 7 months ago

Oh, thanks a lot for the report! :heart:

Yes, you're right of course, just_with_default needs a fwd bind count of 1. :+1:

I just [fixed]() this. :heavy_check_mark: