-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
I tried to compile this code with C++23 to see move_only_function working:
#include <cstdio>
#include <functional>
#include <memory>
using namespace std;
int main()
{
std::move_only_function<void(void)> a1 = [a=make_unique<int>(42)]() {};
}but I noticed that the code generated for the lambda itself is incorrect. Here is the full output
#include <cstdio>
#include <functional>
#include <memory>
using namespace std;
int main()
{
class __lambda_9_46
{
public:
inline /*constexpr */ void operator()() const
{
}
private:
std::unique_ptr<int, std::default_delete<int> > a;
public:
// inline __lambda_9_46(const __lambda_9_46 &) /* noexcept */ = delete;
// inline /*constexpr */ __lambda_9_46(__lambda_9_46 &&) noexcept = default;
// inline __lambda_9_46 & operator=(const __lambda_9_46 &) /* noexcept */ = delete;
__lambda_9_46(const std::unique_ptr<int, std::default_delete<int> > & _a)
: a{_a}
{}
};
std::move_only_function<void ()> a1 = std::move_only_function<void ()>(__lambda_9_46{std::make_unique<int>(42)});
return 0;
}The constructor for this lambda should take the argument by r-value reference, because otherwise this code cannot compile.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working