Commit 5904c0ae authored by James Sedgwick's avatar James Sedgwick Committed by Alecs King

fix collect() for move-only types

Summary:
as above. it never ends.

Test Plan: added unit

Reviewed By: hans@fb.com

Subscribers: folly-diffs@, jsedgwick, yfeldblum, chalfant

FB internal diff: D2011569

Signature: t1:2011569:1429660210:930cb17682d5c86a11881a23efe0a91f4c6a36b1
parent cd338595
......@@ -602,8 +602,8 @@ template <class, class, typename = void> struct CollectContextHelper;
template <class T, class VecT>
struct CollectContextHelper<T, VecT,
typename std::enable_if<std::is_same<T, VecT>::value>::type> {
static inline std::vector<T>& getResults(std::vector<VecT>& results) {
return results;
static inline std::vector<T>&& getResults(std::vector<VecT>& results) {
return std::move(results);
}
};
......
......@@ -877,6 +877,18 @@ TEST(Future, collect) {
EXPECT_THROW(allf.value(), eggs_t);
}
// move only compiles
{
vector<Promise<unique_ptr<int>>> promises(10);
vector<Future<unique_ptr<int>>> futures;
for (auto& p : promises)
futures.push_back(p.getFuture());
collect(futures.begin(), futures.end());
}
}
struct NotDefaultConstructible {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment