Skip to content

Commit

Permalink
Make Polly work with MSVC
Browse files Browse the repository at this point in the history
Summary: MSVC fails to deduce template parameter for a `get` call when the argument is inherited from `std::tuple`. Workaround this by converting the argument to tuple explicitly.

Reviewed By: Orvid

Differential Revision: D59301411

fbshipit-source-id: 61128b4599a78887ad52f6db6a1ff30e0f70df28
  • Loading branch information
vitaut authored and facebook-github-bot committed Jul 3, 2024
1 parent 03041f0 commit ec9e8d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions folly/detail/PolyDetail.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ struct VTable<I, PolyMembers<Arch...>, TypeList<S...>>

State state_;
void* (*ops_)(Op, Data*, void*);

std::tuple<SignatureOf<Arch, I>...>& tuple() { return *this; }
const std::tuple<SignatureOf<Arch, I>...>& tuple() const { return *this; }
};

template <class I>
Expand Down Expand Up @@ -757,12 +760,13 @@ struct PolyNode : Tail {

template <std::size_t K, typename... As>
decltype(auto) _polyCall_(As&&... as) {
return std::get<K>(select<I>(*PolyAccess::vtable(*this)))(
// Convert VTable to tuple explicitly to workaround an MSVC bug.
return std::get<K>(select<I>(*PolyAccess::vtable(*this)).tuple())(
*PolyAccess::data(*this), static_cast<As&&>(as)...);
}
template <std::size_t K, typename... As>
decltype(auto) _polyCall_(As&&... as) const {
return std::get<K>(select<I>(*PolyAccess::vtable(*this)))(
return std::get<K>(select<I>(*PolyAccess::vtable(*this)).tuple())(
*PolyAccess::data(*this), static_cast<As&&>(as)...);
}
};
Expand Down

0 comments on commit ec9e8d8

Please sign in to comment.