Skip to content

Commit

Permalink
Avoid specializing templates within an outer class
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam Mitchell committed Oct 20, 2021
1 parent 20ca243 commit 7c29937
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions include/EASTL/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -1282,36 +1282,36 @@ namespace eastl

};


// abstracts calling visit on a single variant with return types convertible to R
struct visitor_caller_one_r
template <typename R>
struct visitor_r
{
template <typename R>
struct visitor_r
template <typename Visitor, typename Variant, size_t I>
static EA_CONSTEXPR R invoke_visitor_r(Visitor&& visitor, Variant&& variant)
{
template <typename Visitor, typename Variant, size_t I>
static EA_CONSTEXPR R invoke_visitor_r(Visitor&& visitor, Variant&& variant)
{
return eastl::invoke(eastl::forward<Visitor>(visitor),
eastl::get<I>(eastl::forward<Variant>(variant)));
}
};
return eastl::invoke(eastl::forward<Visitor>(visitor),
eastl::get<I>(eastl::forward<Variant>(variant)));
}
};

// void return type must discard the return values of the visitor even if the visitor returns a value.
template <>
struct visitor_r<void>
// void return type must discard the return values of the visitor even if the visitor returns a value.
template <>
struct visitor_r<void>
{
template <typename Visitor, typename Variant, size_t I>
static EA_CONSTEXPR void invoke_visitor_r(Visitor&& visitor, Variant&& variant)
{
template <typename Visitor, typename Variant, size_t I>
static EA_CONSTEXPR void invoke_visitor_r(Visitor&& visitor, Variant&& variant)
{
eastl::invoke(eastl::forward<Visitor>(visitor),
eastl::get<I>(eastl::forward<Variant>(variant)));
}
};
template<> struct visitor_r<const void> : public visitor_r<void> {};
template<> struct visitor_r<volatile void> : public visitor_r<void> {};
template<> struct visitor_r<const volatile void> : public visitor_r<void> {};
eastl::invoke(eastl::forward<Visitor>(visitor),
eastl::get<I>(eastl::forward<Variant>(variant)));
}
};

template<> struct visitor_r<const void> : public visitor_r<void> {};
template<> struct visitor_r<volatile void> : public visitor_r<void> {};
template<> struct visitor_r<const volatile void> : public visitor_r<void> {};

// abstracts calling visit on a single variant with return types convertible to R
struct visitor_caller_one_r
{
template <typename R, typename Visitor, typename Variant, size_t... VariantArgIndices>
static EA_CPP14_CONSTEXPR decltype(auto) call_index_r(Visitor&& visitor, Variant&& variant, eastl::index_sequence<VariantArgIndices...>)
{
Expand Down

0 comments on commit 7c29937

Please sign in to comment.