How does Eric Niebler's implementation of std::is_function work? : <p>Last week Eric Niebler <a href="https://twitter.com/ericniebler/status/852192542653329408" rel="noreferrer">tweeted</a> a very compact implementation for the <a href="http://en.cppreference.com/w/cpp/types/is_function" rel="noreferrer"><code>std::is_function</code></a> traits class:</p>

<pre><code>#include &lt;type_traits&gt;

template&lt;int I&gt; struct priority_tag : priority_tag&lt;I - 1&gt; {};
template&lt;&gt; struct priority_tag&lt;0&gt; {};

// Function types here:
template&lt;typename T&gt;
char(&amp;is_function_impl_(priority_tag&lt;0&gt;))[1];

// Array types here:
template&lt;typename T, typename = decltype((*(T*)0)[0])&gt;
char(&amp;is_function_impl_(priority_tag&lt;1&gt;))[2];

// Anything that can be returned from a function here (including
// void and reference types):
template&lt;typename T, typename = T(*)()&gt;
char(&amp;is_function_impl_(priority_tag&lt;2&gt;))[3];

// Classes and unions (including abstract types) here:
template&lt;typename T, typename = int T::*&gt;
char(&amp;is_function_impl_(priority_tag&lt;3&gt;))[4];

template &lt;typename T&gt;
struct is_function
    : std::integral_constant&lt;bool, sizeof(is_function_impl_&lt;T&gt;(priority_tag&lt;3&gt;{})) == 1&gt;
{};
</code></pre>

<p>But how does it work?</p>
