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
This commit is contained in:
James Sedgwick
2015-04-27 16:49:02 -07:00
committed by Alecs King
parent cd338595aa
commit 5904c0ae09
2 changed files with 14 additions and 2 deletions
+2 -2
View File
@@ -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);
}
};
+12
View File
@@ -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 {