How to implement a less generic std::is_constructible with decltype
<p>I'm going out on a limb here, assuming that it is possible but I'm not quite sure. Basically what I'm looking for is a way to switch at compile-time between using a default constructor or a constructor that takes one argument by reference.</p>

<p>i.e.</p>

<pre><code>T* create&lt;T&gt;()
{
    return new T(1); // if possible
}

T* create&lt;T&gt;()
{
    return new T(); // fallback to here
}
</code></pre>

<p>I'm using the VS2010 compiler and it does not support <code>std::is_constructible</code> but I can use <code>decltype</code>.</p>

<p>I went digging in the VS2012 type_traits header and looked at the <code>std::is_constructible</code> implementation and well I got a bit turned around. I don't get it how people write code that way. The headers are the most convoluted piece of code I've ever seen. Anyway, I saw that it was using decltype and it got me think, hopefully someone with more experienced can provide me with an answer.</p>

<p><strong>After going through @ipc's answer I've settled on the following code</strong></p>

<pre><code>// std::declval is not supported by VS2010
template &lt;typename T&gt; typename std::add_rvalue_reference&lt;T&gt;::type declval();

template &lt;class T, class R0&gt;
decltype(new T(declval&lt;R0&gt;()))
createInstance_(R0&amp; r0, int = 0)
{
    return new T(r0);
}

template &lt;class T, class R0&gt;
T*
createInstance_(R0&amp;, ...)
{
    return new T();
}
</code></pre>

<p>The above code will work but it does confuse the IntelliSense Engine, anyway I thought it was nice that you could omit the extra function by simply using a default argument. I've tested this code with VS 2010 and it compiles fine and runs as expected.</p>
