Note that there are some explanatory texts on larger screens.

plurals
  1. POCan type to value meta-function be used as variable alias in C++14?
    text
    copied!<p>While looking at C++14 the meta-function alias proposals (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3655.pdf" rel="nofollow">TransformationTraits Redux, v2,N3655</a>), I noticed that, not only type to type transformations (such as <code>add_const</code>), type to value meta-functions (such as <code>is_void</code> ) are also type aliased. (Which are not present in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf" rel="nofollow">N3797</a>). </p> <p>Is there any advantage of aliasing type to value meta-functions? I think, it is possible to use them without those aliases, such as <code>enable_if_t&lt;is_void&lt;T&gt;::value,T&gt;</code> or <code>enable_if_t&lt;is_void&lt;T&gt;{}(),T&gt;</code> when the conversion operation is present. (I guess <code>is_void&lt;T&gt;::type::value</code> is same as <code>is_void&lt;T&gt;::value</code>)</p> <p>If the type to value meta-functions need to be aliases, wont it be better to alias them as variable template ( I do not have C++14 compiler and never used variable template. So the syntax may be wrong)? e.g. alias <code>is_void</code> as </p> <pre><code>template &lt;class T&gt; constexpr bool is_void_t = is_void&lt;T&gt;::value; </code></pre> <p>Instead of </p> <pre><code>template &lt;class T&gt; using is_void_t = typename is_void&lt;T&gt;::type; </code></pre> <p>Then one can write <code>enable_if_t&lt;is_void_t&lt;T&gt;,T&gt;</code> without boost style <code>enable_if</code>,and composing expression will be easier (e.g. <code>enable_if_t&lt;(is_void_t&lt;T&gt; || is_integral_t&lt;T&gt;),T&gt;</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload