Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use a simple type function based on partial specialization of a class template:</p> <pre><code>#include &lt;type_traits&gt; #include &lt;tuple&gt; using namespace std; template&lt;typename T&gt; struct remove_first_type { }; template&lt;typename T, typename... Ts&gt; struct remove_first_type&lt;tuple&lt;T, Ts...&gt;&gt; { typedef tuple&lt;Ts...&gt; type; }; int main() { typedef tuple&lt;int, bool, double&gt; my_tuple; typedef remove_first_type&lt;my_tuple&gt;::type my_tuple_wo_first_type; static_assert( is_same&lt;my_tuple_wo_first_type, tuple&lt;bool, double&gt;&gt;::value, "Error!" ); } </code></pre> <p>Also, this solution can be easily generalized to remove the <strong>i-th</strong> type of a tuple:</p> <pre><code>#include &lt;type_traits&gt; #include &lt;tuple&gt; using namespace std; template&lt;size_t I, typename T&gt; struct remove_ith_type { }; template&lt;typename T, typename... Ts&gt; struct remove_ith_type&lt;0, tuple&lt;T, Ts...&gt;&gt; { typedef tuple&lt;Ts...&gt; type; }; template&lt;size_t I, typename T, typename... Ts&gt; struct remove_ith_type&lt;I, tuple&lt;T, Ts...&gt;&gt; { typedef decltype( tuple_cat( declval&lt;tuple&lt;T&gt;&gt;(), declval&lt;typename remove_ith_type&lt;I - 1, tuple&lt;Ts...&gt;&gt;::type&gt;() ) ) type; }; int main() { typedef tuple&lt;int, bool, double&gt; my_tuple; typedef remove_ith_type&lt;1, my_tuple&gt;::type my_tuple_wo_2nd_type; static_assert( is_same&lt;my_tuple_wo_2nd_type, tuple&lt;int, double&gt;&gt;::value, "Error!" ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload