How to order types at compile-time? : <p>Consider the following program:</p>

<pre><code>#include &lt;tuple&gt;
#include &lt;vector&gt;
#include &lt;iostream&gt;
#include &lt;type_traits&gt;

template &lt;class T&gt;
struct ordered {};

template &lt;class... T&gt;
struct ordered&lt;std::tuple&lt;T...&gt;&gt;
{
    using type = /* a reordered tuple */;
};

template &lt;class T&gt;
using ordered_t = typename ordered&lt;T&gt;::type;

int main(int argc, char* argv[])
{
    using type1 = std::tuple&lt;char, std::vector&lt;int&gt;, double&gt;;
    using type2 = std::tuple&lt;std::vector&lt;int&gt;, double, char&gt;;
    std::cout &lt;&lt; std::is_same_v&lt;type1, type2&gt; &lt;&lt; "\n"; // 0
    std::cout &lt;&lt; std::is_same_v&lt;ordered_t&lt;type1&gt;, ordered_t&lt;type2&gt;&gt; &lt;&lt; "\n"; // 1
    return 0;
}
</code></pre>

<p>The <code>ordered</code> helper has to reorder types in a tuple, such that two tuples with the sames types, but ordered differently lead to the same tuple type: which can be the first one, the second one, or even another one: it just has to have the same size, and the same elements but in a unique order (regardless of this order).</p>

<p>Is it possible to do this at compile-time using template metaprogramming techniques?</p>
