Finding the common iterator category in C++ I created a template trait which finds the common iterator category between a set of given iterator categories. More specifically, it's a class with a member type alias to one of the iterator tags which is the most efficient for the specific requirement set that is implied by both categories given as template arguments (the least "powerful" in the iterator hierarchy).

For example, given std::forward_iterator_tag, std::random_access_iterator_tag and std::bidirectional_iterator_tag, it provide std::forward_iterator_tag. 

If all the given types are std::output_iterator_tag then it will provide std::output_iterator_tag. Otherwise, there is no member type alias. (std::output_iterator_tag must be treated differently because it is not in the input iterator hierarchy.)  

#include &lt;algorithm&gt;
#include &lt;iterator&gt;
#include &lt;tuple&gt;
#include &lt;type_traits&gt;

namespace detail {
    // Gets the index of the first occurrence of a type in a tuple (inverse of std::tuple_element_t).
    template &lt;typename T, class Tuple&gt;
    struct tuple_type_index;

    // Specialisation for match on parameter pack's first type.
    template&lt;typename T, typename... Ts&gt;
    struct tuple_type_index&lt;T, std::tuple&lt;T, Ts...&gt;&gt; : std::integral_constant&lt;std::size_t, 0&gt; {};

    // Specialisation for no match on parameter pack's first type.
    template&lt;typename T, typename U, typename... Ts&gt;
    struct tuple_type_index&lt;T, std::tuple&lt;U, Ts...&gt;&gt; : std::integral_constant&lt;std::size_t, 1 + tuple_type_index&lt;T, std::tuple&lt;Ts...&gt;&gt;::value&gt; {};

    // Helper variable template.
    template&lt;typename T, class Tuple&gt;
    constexpr std::size_t tuple_type_index_v = tuple_type_index&lt;T, Tuple&gt;::value;


    // Hierarchy of input iterator categories (output iterator category is handled separately) from least to most powerful.
    using iterator_categories = std::tuple&lt;std::input_iterator_tag, std::forward_iterator_tag, std::bidirectional_iterator_tag, std::random_access_iterator_tag&gt;;
}


// Primary template (for 0 categories).
template&lt;class... IteratorCategories&gt;
struct common_iterator_category {};

// Helper type alias.
template&lt;class... IteratorCategories&gt;
using common_iterator_category_t = typename common_iterator_category&lt;IteratorCategories...&gt;::type;

// Specialisation for 1 category.
template&lt;class IteratorCategory&gt;
struct common_iterator_category&lt;IteratorCategory&gt; {
    using type = IteratorCategory;
};

// Specialisation for 2 non-output-iterator categories.
template&lt;class IteratorCategory1, class IteratorCategory2&gt;
struct common_iterator_category&lt;IteratorCategory1, IteratorCategory2&gt; {
    using type = std::tuple_element_t&lt;
        std::min(
            detail::tuple_type_index_v&lt;IteratorCategory1, detail::iterator_categories&gt;,
            detail::tuple_type_index_v&lt;IteratorCategory2, detail::iterator_categories&gt;),
        detail::iterator_categories&gt;;
};

// Specialisation for 2 output iterator categories.
template&lt;&gt;
struct common_iterator_category&lt;std::output_iterator_tag, std::output_iterator_tag&gt; {
    using type = std::output_iterator_tag;
};

// Specialisation for 3+ categories.
template&lt;class IteratorCategory1, class IteratorCategory2, class... IteratorCategories&gt;
struct common_iterator_category&lt;IteratorCategory1, IteratorCategory2, IteratorCategories...&gt; :
    common_iterator_category&lt;common_iterator_category_t&lt;IteratorCategory1, IteratorCategory2&gt;, common_iterator_category_t&lt;IteratorCategories...&gt;&gt; {};


The code with tests/examples is live here.

I am specifically interested in feedback with regards to the conciseness/efficiency of the design, and also whether it is well formed (I am worried about UB but "happens to work" or no diagnostic required issues). I'm not so much concerned with the tuple_type_index utility (it's just there because it happens to be required). But feedback of any sort is of course welcome.
If you have a typelist of iterator tag types, then std::common_type will find the common base type.  

using InTag = std::istream_iterator&lt;int&gt;::iterator_category;
using BdTag = std::list&lt;int&gt;::iterator::iterator_category;
using RaTag = std::vector&lt;int&gt;::iterator::iterator_category;

static_assert(std::is_same_v&lt;std::common_type_t&lt;InTag, BdTag&gt;, std::input_iterator_tag&gt;);
static_assert(std::is_same_v&lt;std::common_type_t&lt;InTag, RaTag&gt;, std::input_iterator_tag&gt;);
static_assert(std::is_same_v&lt;std::common_type_t&lt;BdTag, RaTag&gt;, std::bidirectional_iterator_tag&gt;);


If you are unwrapping the tag type at the call site, just have the trait do it.

template &lt;class... Iterators&gt;
struct common_iterator_tag 
: std::common_type&lt;typename std::iterator_traits&lt;Iterators&gt;::iterator_category...&gt;
{
};

template &lt;class... Iterators&gt;
using common_iterator_tag_t = typename common_iterator_tag&lt;Iterators...&gt;::type;

using RaIter = std::vector&lt;int&gt;::iterator;
using InIter = std::istream_iterator&lt;int&gt;::iterator;

static_assert(std::is_same_v&lt;std::input_iterator_tag, common_iterator_tag_t&lt;RaIter, InIter&gt;&gt;);

using BackIter = std::back_insert_iterator&lt;std::vector&lt;int&gt;&gt;;
using InsertIter = std::insert_iterator&lt;std::list&lt;int&gt;&gt;;

static_assert(std::is_same_v&lt;std::output_iterator_tag, common_iterator_tag_t&lt;BackIter, InsertIter&gt;&gt;);