mirror of
https://github.com/clearlinux/folly.git
synced 2026-09-01 11:15:52 +00:00
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:
committed by
Alecs King
parent
cd338595aa
commit
5904c0ae09
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user