Skip to content

just fails with a lambda with capture #144

@steve-downey

Description

@steve-downey
#include <beman/execution/execution.hpp>
#include <stdexec/execution.hpp>

namespace bex = beman::execution;
namespace sex = stdexec;

int main() {
    double d = 19.0;
    auto j1 = bex::just([](auto l) { return l; },
                        [d](auto r) { return d; });

    auto j2 = sex::just([](auto l) { return l; },
                        [d](auto r) { return d; });

    return 0;
}

https://compiler-explorer.com/z/3bf7M4E5e

<source>:9:15: error: no matching function for call to object of type 'const ::beman::execution::just_t' (aka 'const just_t< ::beman::execution::set_value_t>')
    9 |     auto j1 = bex::just([](auto l) { return l; },
      |               ^~~~~~~~~
/opt/compiler-explorer/libs/beman_execution/main/include/beman/execution/detail/just.hpp:31:10: note: candidate template ignored: constraints not satisfied [with T = <(lambda at <source>:9:25), (lambda at <source>:10:25)>]
   31 |     auto operator()(T&&... arg) const {
      |          ^
/opt/compiler-explorer/libs/beman_execution/main/include/beman/execution/detail/just.hpp:30:78: note: because '::std::decay_t<(lambda at <source>:10:25)>' (aka '(lambda at <source>:10:25)') does not satisfy 'movable'
   30 |         requires ::beman::execution::detail::just_size<Completion, T...> && (::std::movable<::std::decay_t<T>> && ...)
      |                                                                              ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/concepts:274:10: note: because 'assignable_from<(lambda at <source>:10:25) &, (lambda at <source>:10:25)>' evaluated to false
  274 |       && assignable_from<_Tp&, _Tp> && swappable<_Tp>;
      |          ^
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../include/c++/16.0.0/concepts:152:10: note: because '__lhs = static_cast<_Rhs &&>(__rhs)' would be invalid: object of type '(lambda at <source>:10:25)' cannot be assigned because its copy assignment operator is implicitly deleted
  152 |         { __lhs = static_cast<_Rhs&&>(__rhs) } -> same_as<_Lhs>;
      |                 ^
1 error generated.
Compiler returned: 1

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