SFINAE with several condition [Refactoring] How can I write this function shorter?

template&lt;typename U, typename = typename std::enable_if&lt;std::is_fundamental&lt;U&gt;::value&gt;::type,
    typename = typename std::enable_if&lt;!std::is_same&lt;char, U&gt;::value&gt;::type,
    typename = typename std::enable_if&lt;!std::is_same&lt;void, U&gt;::value&gt;::type
&gt;
void multiply(U&amp;&amp; u){};


I want exclude several type like void or char, which don't must be number. I wrote code like this, but I think, that is better solution. (code of course is correctly)
Seems short enough to me.

It's impossible to know how to refactor any code without first knowing what it is supposed to do. All we know about this no-op function is that you "want [to] exclude several type[s] like void or char". How many types? Which types? Why?



The obvious shortening is

template&lt;class U, class = std::enable_if_t&lt;std::is_fundamental_v&lt;U&gt;&gt;,
    class = std::enable_if_t&lt;!std::is_same_v&lt;char, U&gt; &amp;&amp; !std::is_same_v&lt;void, U&gt;&gt;
&gt;
void multiply(U&amp;&amp;) {}


i.e. just remove all the superfluous ::type and ::value, and replace typename by class because it's shorter (and you did ask for us to make it shorter!).



Your naming the function multiply implies that maybe what you want is

template&lt;class U&gt;
auto multiply(U&amp;&amp; u) -&gt; decltype(u*u, void()) {}




Your comments about "don't must be number" imply that maybe what you want is

template&lt;class U, class = std::enable_if_t&lt;std::is_arithmetic_v&lt;U&gt;&gt;&gt;
void multiply(U&amp;&amp;) {}


But we really can't know for sure unless you tell us what the code is supposed to do.