C++ template function resolution
<p>I've got the following sample code and would like to get some help to understand why I am unable to compile it using clang and g++ on Linux?</p>

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

using namespace std;

typedef enum COLORS {
    RED = 0,
    GREEN,
    BLUE,
    ORANGE,
    MAROON,
    WHITE,
    BLACK
} COLORS;

template &lt;COLORS C&gt; void whatColor( COLORS x ) {
    cout &lt;&lt; "this can be any color!!!" &lt;&lt; endl;
}

template&lt;&gt; void whatColor&lt;RED&gt;( COLORS x ) {
    cout &lt;&lt; "this is RED!!!" &lt;&lt; endl;
}

template&lt;&gt; void whatColor&lt;GREEN&gt;( COLORS x ) {
    cout &lt;&lt; "this is GREEN!!!" &lt;&lt; endl;
}

template&lt;&gt; void whatColor&lt;BLUE&gt;( COLORS x ) {
    cout &lt;&lt; "this is BLUE!!!" &lt;&lt; endl;
}

template&lt;&gt; void whatColor&lt;ORANGE&gt;( COLORS x ) {
    cout &lt;&lt; "this is ORANGE!!!" &lt;&lt; endl; 
}

int main( ) {
    const COLORS red=RED;

    whatColor( red );
    whatColor&lt;RED&gt;( RED );
    whatColor&lt;red&gt;( red );
    whatColor&lt;RED&gt;( red );
}
</code></pre>

<p>The failure I am seeing is this:</p>

<pre><code>CXX [misc]  tmpl.cpp
src/tmpl.cpp:40:2: error: no matching function for call to 'whatColor'
    whatColor( red );
    ^~~~~~~~~
src/tmpl.cpp:15:26: note: candidate template ignored: couldn't infer template argument 'C'
template &lt;COLORS C&gt; void whatColor( COLORS x ) {
                     ^
1 error generated.
make: *** [obj/tmpl.o] Error 1
</code></pre>

<p>It is unclear to me why it cannot infer the argument type in this case</p>