Skip to content

Commit

Permalink
Avoid using std::views::filter to fix issues with macosx-x86_64 toolc…
Browse files Browse the repository at this point in the history
…hain (#42076)

Summary:
Pull Request resolved: #42076

## Changelog:
[Internal] -

In #41519 we introduced usage of C++20s range operations, which broke MacOSX desktop builds for the x86_64 targets (e.g. on Intel Mac laptops).

This appears to be a [known issue](https://stackoverflow.com/questions/73929080/error-with-clang-15-and-c20-stdviewsfilter), fixed in the later clang versions, however we need to support the earlier ones as well.

This changes the code to use the good old imperative style to do the same thing, but without using `std::views::filter`, thus working around the problem.

Reviewed By: christophpurrer

Differential Revision: D52428984

fbshipit-source-id: 6d0a390549c462b7040b5c0e669c00932bd99af7
  • Loading branch information
rshest authored and facebook-github-bot committed Dec 27, 2023
1 parent c2c346c commit ffe219c
Showing 1 changed file with 16 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,22 @@ std::tuple<EventPath, EventPath> PointerHoverTracker::diffEventPath(
++otherIt;
}

auto removedViews =
std::ranges::subrange{myIt, myEventPath.rend()} |
std::views::transform(
[this, &uiManager](const ShadowNode& node) -> const ShadowNode* {
return this->getLatestNode(node, uiManager);
}) |
std::views::filter([](auto n) -> bool { return n != nullptr; }) |
std::views::transform([](auto n) -> ShadowNode const& { return *n; });
EventPath removed(removedViews.begin(), removedViews.end());

auto addedViews =
std::ranges::subrange{otherIt, otherEventPath.rend()} |
std::views::transform(
[&other, &uiManager](const ShadowNode& node) -> const ShadowNode* {
return other.getLatestNode(node, uiManager);
}) |
std::views::filter([](auto n) -> bool { return n != nullptr; }) |
std::views::transform([](auto n) -> ShadowNode const& { return *n; });
EventPath added(addedViews.begin(), addedViews.end());
EventPath removed;
for (const auto& node : std::ranges::subrange{myIt, myEventPath.rend()}) {
const auto& latestNode = getLatestNode(node, uiManager);
if (latestNode != nullptr) {
removed.push_back(*latestNode);
}
}

EventPath added;
for (const auto& node :
std::ranges::subrange{otherIt, otherEventPath.rend()}) {
const auto& latestNode = other.getLatestNode(node, uiManager);
if (latestNode != nullptr) {
added.push_back(*latestNode);
}
}

return std::make_tuple(removed, added);
}
Expand Down

0 comments on commit ffe219c

Please sign in to comment.