Skip to content

Commit

Permalink
tweak RegexMatchCacheKey conversion to use variable template
Browse files Browse the repository at this point in the history
Summary: Some versions of MSVC fail to compile with an argument passed to the function template.

Reviewed By: Gownta

Differential Revision: D64643990

fbshipit-source-id: f988a618b8c163c1bd930c091cc06076b0960ba7
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Oct 24, 2024
1 parent 7cdb09f commit 039c757
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions folly/container/RegexMatchCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,16 +391,15 @@ class RegexMatchCacheKey {

static data_type init(std::string_view regex) noexcept;

template <typename T, typename V = std::remove_cv_t<T>>
static constexpr bool is_span_compatible() noexcept {
return //
!std::is_volatile_v<T> && //
std::is_integral_v<V> && //
std::is_unsigned_v<V> && //
!std::is_same_v<bool, V> && //
!std::is_same_v<char, V> && //
alignof(V) <= data_align;
}
template <typename T, size_t E, typename V = std::remove_cv_t<T>>
static constexpr bool is_span_compatible_v = //
!std::is_volatile_v<T> && //
std::is_integral_v<V> && //
std::is_unsigned_v<V> && //
!std::is_same_v<bool, V> && //
!std::is_same_v<char, V> && //
alignof(V) <= data_align && //
(E == data_size / sizeof(T) || E == dynamic_extent);

public:
explicit RegexMatchCacheKey(std::string_view regex) noexcept
Expand All @@ -409,10 +408,7 @@ class RegexMatchCacheKey {
template <
typename T,
std::size_t E,
std::enable_if_t<
is_span_compatible<T>() &&
(E == data_size / sizeof(T) || E == dynamic_extent),
int> = 0>
std::enable_if_t<is_span_compatible_v<T, E>, int> = 0>
explicit operator span<T const, E>() const noexcept {
return {reinterpret_cast<T const*>(data_.data()), E};
}
Expand Down

0 comments on commit 039c757

Please sign in to comment.