title: Implementing std::variant converting constructor - or: how to find first overload of all conversions from any T to Ti from parameter pack
body: <p>In the latest <a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2016/n4606.pdf" rel="noreferrer">working draft</a> (page 572) of the C++ standard the converting constructor of <code>std::variant</code> is annotated with:</p>
  
  <pre><code>template &lt;class T&gt; constexpr variant(T&amp;&amp; t) noexcept(see below );
  </code></pre>
  
  <blockquote>
    <p>Let Tj be a type that is determined as follows: build an imaginary function FUN (Ti) for each alternative type Ti. The overload FUN (Tj) selected by overload resolution for the expression <code>FUN (std::forward&lt;T&gt;(t))</code> defines the alternative Tj which is the type of the contained value after construction.</p>
    
    <p><strong>Effects:</strong> Initializes *this to hold the alternative type Tj and
    direct-initializes the contained value as if
    direct-non-list-initializing it with <code>std::forward&lt;T&gt;(t)</code>.</p>
    
    <p>[...]</p>
    
    <p><strong>Remarks:</strong> This function shall not participate in overload resolution unless <code>is_same_v&lt;decay_t&lt;T&gt;, variant&gt;</code> is false, unless
    <code>is_constructible_v&lt;Tj, T&gt;</code> is true, and unless the expression <code>FUN ( std::forward&lt;T&gt;(t))</code> (with FUN being the above-mentioned set of
    imaginary functions) is well formed.</p>
  </blockquote>
  
  <p>On <a href="http://en.cppreference.com/w/cpp/utility/variant/variant" rel="noreferrer">cppreference</a> the following example is used to illustrate the conversion:</p>
  
  <pre><code>variant&lt;string&gt; v("abc"); // OK
  variant&lt;string, string&gt; w("abc"); // ill-formed, can't select the alternative to convert to
  variant&lt;string, bool&gt; x("abc"); // OK, but chooses bool
  </code></pre>
  
  <p>How can you mimic the <em>imaginary overload resolution</em> to obtain the final type <code>Tj</code>?</p>