Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two syntaxes to denote array types. The first is the <strong>type-id</strong> syntax and is used everywhere where the language expects a compile time type, which looks like:</p> <pre><code>T[constant-expression] T[] </code></pre> <p>This specifies an array type that, in the first form, has a number of elements given by an integer constant expression (means it has to be known at compile time). In the second form, it specifies an array type with an unknown number of elements. Similar to class types that you declare without a body, such an array type is said to be <em>incomplete</em>, and you cannot create arrays of that type</p> <pre><code>// not valid: what size would it have? int a[]; </code></pre> <p>You can, however, <em>specify</em> that type. For example you may typedef it</p> <pre><code>typedef int unknown_int_array[]; </code></pre> <p>In the same manner, you may specify it as a template type argument, so the answer to your question is <em>yes</em> you can pass such a type <em>specifier</em> to a template. Notice that i talk about specifiers here, because the form you use here is not the type itself. </p> <p>The second way is using the <strong>new-type-id</strong> syntax which allows denoting runtime types by having non-constant bounds</p> <pre><code>T[expression] </code></pre> <p>This allows passing variables as element count, and also allows passing a <strong>zero</strong>. In such a case, a zero element array is created. That syntax is only usable with the <code>new</code> operator for supporting dynamic arrays.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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