diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index a5c45a21a2401..5923fdd46a378 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -535,31 +535,22 @@ class filter_iterator_impl struct fwd_or_bidi_tag_impl { - using type = std::forward_iterator_tag; -}; - -template <> struct fwd_or_bidi_tag_impl { - using type = std::bidirectional_iterator_tag; -}; - -/// Helper which sets its type member to forward_iterator_tag if the category -/// of \p IterT does not derive from bidirectional_iterator_tag, and to -/// bidirectional_iterator_tag otherwise. -template struct fwd_or_bidi_tag { - using type = typename fwd_or_bidi_tag_impl::iterator_category>::value>::type; -}; +/// A type alias which is std::bidirectional_iterator_tag if the category of +/// \p IterT derives from it, and std::forward_iterator_tag otherwise. +template +using fwd_or_bidi_tag = std::conditional_t< + std::is_base_of_v::iterator_category>, + std::bidirectional_iterator_tag, std::forward_iterator_tag>; } // namespace detail /// Defines filter_iterator to a suitable specialization of /// filter_iterator_impl, based on the underlying iterator's category. template -using filter_iterator = filter_iterator_impl< - WrappedIteratorT, PredicateT, - typename detail::fwd_or_bidi_tag::type>; +using filter_iterator = + filter_iterator_impl>; /// Convenience function that takes a range of elements and a predicate, /// and return a new filter_iterator range.