Using std::visit with variadic template struct : <p>I was trying to understand the following example which I got from <a href="http://en.cppreference.com/w/cpp/utility/variant/visit" rel="noreferrer">http://en.cppreference.com/w/cpp/utility/variant/visit</a></p>

<pre><code>#include &lt;iomanip&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;type_traits&gt;
#include &lt;variant&gt;
#include &lt;vector&gt;


using var_t = std::variant&lt;int, long, double, std::string&gt;;

template&lt;class... Ts&gt; struct overloaded : Ts... { using Ts::operator()...; };
// what is this declaration imply???
template&lt;class... Ts&gt; overloaded(Ts...) -&gt; overloaded&lt;Ts...&gt;;

int main() {
    std::vector&lt;var_t&gt; vec = {10, 15l, 1.5, "hello"};


    for (auto&amp; v: vec) {
        std::visit(overloaded {
            [](auto arg) { std::cout &lt;&lt; arg &lt;&lt; '\n'; },
            [](double arg) { std::cout &lt;&lt; std::fixed &lt;&lt; arg &lt;&lt; '\n'; },
            [](const std::string&amp; arg) { std::cout &lt;&lt; std::quoted(arg) &lt;&lt; '\n'; },
        }, v);
    }
}
</code></pre>

<p>Can someone please explain how this overloaded struct works? Especially what I didn't understand is the following declaration.</p>

<pre><code>template&lt;class... Ts&gt; overloaded(Ts...) -&gt; overloaded&lt;Ts...&gt;;
</code></pre>

<p>Without this declaration, the compiler issues the following error messages.</p>

<pre><code>main.cpp: In function 'int main()':
main.cpp:26:9: error: class template argument deduction failed:
         }, v);
         ^
main.cpp:26: confused by earlier errors, bailing out
</code></pre>

<p>Purpose: learning</p>
