function template as member - GCC vs. CLANG
<p>Consider the following code:</p>

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

template &lt;typename F&gt;
class function
{
public:
//  using function_type = typename std::decay&lt;F&gt;::type;
    using function_type = F;

    function(F func)
        : function_(func)
    {
    }

private:
     function_type function_;
};

template &lt;typename F&gt;
function&lt;F&gt; make_function(F&amp;&amp; func)
{
    return function&lt;F&gt;(std::forward&lt;F&gt;(func));
}

double f1(double)
{
    return 0.0;
}

template &lt;typename T&gt;
T f2(T)
{
    return T();
}

int main()
{
    // works in both cases
    make_function(f1);

    // needs decay (with CLANG)
    make_function(f2&lt;double&gt;);
}
</code></pre>

<p>The class <code>function</code> is intended to be a simple wrapper for any <code>Callable</code> . The code compiles fine with GCC (I tested both 4.9.2 and 7.0.0 20160427 from the git repository). However, clang (3.5.0) complains:</p>

<pre><code>function.cpp:17:17: error: data member instantiated with function type 'function_type' (aka 'double (double)')
         function_type function_;
                       ^
function.cpp:55:2: note: in instantiation of template class 'function&lt;double (double)&gt;' requested here
        make_function(f2&lt;double&gt;);
</code></pre>

<p>So is this a bug of GCC? Why does it work if the variable is an argument (in <code>make_function</code> and the constructor) but not if it is a member variable? Is the decay (commmented out) in the right place or should I move it into <code>make_function</code>? Why does it make a difference if I pass a function (<code>f1</code>) or an explicit instantation of a function template (<code>f2</code>)?</p>