pipes icon indicating copy to clipboard operation
pipes copied to clipboard

Move-only type support

Open TartanLlama opened this issue 6 years ago • 2 comments

It doesn't look like move-only types or move semantics are supported by the library. As a minimal example, I would have expected this to work:

  std::vector<std::unique_ptr<int>> input{ std::make_unique<int>(0), std::make_unique<int>(1), std::make_unique<int>(2) };
  std::vector<std::unique_ptr<int>> results;

  std::move(input) >>= pipes::funnel >>= std::back_inserter(results);

But it tries to copy the std::unique_ptrs and gives a compiler error.

TartanLlama avatar Aug 14 '19 13:08 TartanLlama

I've attempted to fix this problem with a move pipe with this syntax:

std::vector<std::unique_ptr<int>> input{ std::make_unique<int>(0), std::make_unique<int>(1), std::make_unique<int>(2) };
std::vector<std::unique_ptr<int>> results;
input >>= pipes::move >>= std::back_inserter(results);

What do you think? I'm not 100% convinced with the syntax, the dev is currently in a branch. I don't see how to implement the syntax std::move(input), because we're not moving the container itself (unless I misunderstood your comment).

joboccara avatar Aug 26 '19 08:08 joboccara