Skip to content

Commit

Permalink
simplify some channel test helpers
Browse files Browse the repository at this point in the history
Summary:
* Simplify template specs.
* Use C++17 param-pack folds in place of the C++11 param-pack expansion-into-array trick.

Reviewed By: dmm-fb

Differential Revision: D52875149

fbshipit-source-id: 81e3b2873ac050c9cac9708f47cabc7c259c962f
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Jan 20, 2024
1 parent b930cba commit 311ca18
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions folly/experimental/channels/test/ChannelTestUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ template <typename T, typename... Others>
std::vector<T> toVector(T firstItem, Others... items) {
std::vector<T> itemsVector;
itemsVector.push_back(std::move(firstItem));
[[maybe_unused]] int dummy[] = {
(itemsVector.push_back(std::move(items)), 0)...};
(void(itemsVector.push_back(std::move(items))), ...);
return itemsVector;
}

template <typename TPair, typename... Others>
folly::F14FastMap<typename TPair::first_type, typename TPair::second_type>
toMap(TPair firstPair, Others... items) {
folly::F14FastMap<typename TPair::first_type, typename TPair::second_type>
itemsMap;
template <typename Key, typename Mapped, typename... Others>
folly::F14FastMap<std::remove_const_t<Key>, Mapped> toMap(
std::pair<Key, Mapped> firstPair, Others... items) {
folly::F14FastMap<std::remove_const_t<Key>, Mapped> itemsMap;
itemsMap.insert(std::move(firstPair));
[[maybe_unused]] int dummy[] = {(itemsMap.insert(std::move(items)), 0)...};
(void(itemsMap.insert(std::move(items))), ...);
return itemsMap;
}

Expand Down

0 comments on commit 311ca18

Please sign in to comment.