Deciding size of temporary in template
<p>I have a template class that needs to be able to interpolate between two instances of a type.  So my class calls a user-provided function called <code>interpolate</code>, with the following signature:</p>

<pre><code>template&lt;typename T&gt;
T interpolate(uint32_t distance, const T&amp; from, const T&amp; to);
</code></pre>

<p>Here, <code>distance</code> runs from <code>0</code> to <code>0xFFFF</code>.</p>

<p>Now, I would like to provide sane implementations for common types of <code>T</code>, such as for <code>uint32_t</code>.  So I wrote a sample implementation (ignore that it is only implemented for signed types):</p>

<pre><code>template&lt;typename T&gt;
inline auto interpolate(uint32_t distance, const T&amp; from, const T&amp; to)
    -&gt; std::enable_if_t&lt;std::is_signed&lt;T&gt;::value, T&gt;
{
    return from + ((distance * (to - from)) / 0xFFFF);
}
</code></pre>

<p>This works fine for types that are smaller than 32 bits, because distance is never larger than 16 bits' worth, and the result of <code>distance * (to - from)</code> is <code>uint32_t</code>.  But 32 bits is not enough to contain the result of, say, <code>0xFFFF * uint32_t</code> -- in this case the template would need a 64-bit temporary.</p>

<p>Is there a standardized way I can select a type a "size larger" than <code>T</code> to hold the temporary result in?  Obviously this only needs to work for intrinsic types; users' types will still need their own <code>interpolate</code> implementation.</p>