Naios / continuable

C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections)
https://naios.github.io/continuable/
MIT License
815 stars 44 forks source link

tutorial code does not compile #30

Closed endseeker closed 4 years ago

endseeker commented 4 years ago

@Naios

this code from "Connecting continuables" dosnt compile under Visual studio 2019. error is "attempting to reference a deleted function". I think you are missing a std::move() when calling cti::when_all()

// cti::populate just creates a std::vector from the two continuables. auto v = cti::populate(cti::make_ready_continuable(0), cti::make_ready_continuable(1));

for (int i = 2; i < 5; ++i) { // It is possible to add more continuables // to the container afterwards container.emplace_back(cti::make_ready_continuable(i)); }

cti::when_all(v) .then([](std::vector resolved) { // ... });


Commit Hash

{Please write here}

Expected Behavior

{Please write here}

Actual Behavior

{Please write here}

Steps to Reproduce

{Please write here}

Your Environment

Naios commented 4 years ago

Did you try to move the vector into when_all? Continuable follows strict move on invalidation semantics and thus the copy constructor and copy assign operator is deleted.

cti::when_all(std::move(v))
  .then([](std::vector<int> resolved) {
  // ...
  });
endseeker commented 4 years ago

yes, std::move(v) works.

Naios commented 4 years ago

Perfect, was the code without the move somewhere in the documentation and needs a correction?

endseeker commented 4 years ago

yes, its here toward the bottom: https://naios.github.io/continuable/tutorial-connecting-continuables.html