|
4931 | 4931 | \end{note}
|
4932 | 4932 |
|
4933 | 4933 | \pnum
|
4934 |
| -\indextext{storage duration!dynamic}% |
4935 |
| -Objects created by a \grammarterm{new-expression} have dynamic storage |
4936 |
| -duration\iref{basic.stc.dynamic}. |
4937 |
| -\begin{note} |
4938 |
| -\indextext{\idxcode{new}!scoping and}% |
4939 |
| -The lifetime of such an object is not necessarily restricted to the |
4940 |
| -scope in which it is created. |
4941 |
| -\end{note} |
4942 |
| -When the allocated object is not an array, the result of the \grammarterm{new-expression} |
4943 |
| -is a pointer to the object created. |
4944 |
| - |
4945 |
| -\pnum |
4946 |
| -\indextext{array!\idxcode{new}}% |
4947 |
| -When the allocated object is an array (that is, the |
4948 |
| -\grammarterm{noptr-new-declarator} syntax is used or the |
4949 |
| -\grammarterm{new-type-id} or \grammarterm{type-id} denotes an array type), the |
4950 |
| -\grammarterm{new-expression} yields a pointer to the initial element (if |
4951 |
| -any) of the array. |
4952 |
| -\begin{note} |
4953 |
| -Both \tcode{\keyword{new} \keyword{int}} and \tcode{\keyword{new} \keyword{int}[10]} have type \tcode{\keyword{int}*} and |
4954 |
| -the type of \tcode{\keyword{new} \keyword{int}[i][10]} is \tcode{\keyword{int} (*)[10]} |
4955 |
| -\end{note} |
4956 | 4934 | The \grammarterm{attribute-specifier-seq} in a \grammarterm{noptr-new-declarator} appertains
|
4957 | 4935 | to the associated array type.
|
4958 | 4936 |
|
|
5033 | 5011 | When the value of the \grammarterm{expression} is zero, the allocation
|
5034 | 5012 | function is called to allocate an array with no elements.
|
5035 | 5013 |
|
| 5014 | +\pnum |
| 5015 | +\indextext{storage duration!dynamic}% |
| 5016 | +Objects created by a \grammarterm{new-expression} have dynamic storage |
| 5017 | +duration\iref{basic.stc.dynamic}. |
| 5018 | +\begin{note} |
| 5019 | +\indextext{\idxcode{new}!scoping and}% |
| 5020 | +The lifetime of such an object is not necessarily restricted to the |
| 5021 | +scope in which it is created. |
| 5022 | +\end{note} |
| 5023 | + |
| 5024 | +\pnum |
| 5025 | +\indextext{array!\idxcode{new}}% |
| 5026 | +When the allocated type is ``array of \tcode{N} \tcode{T}'' |
| 5027 | +(that is, the \grammarterm{noptr-new-declarator} syntax is used or the |
| 5028 | +\grammarterm{new-type-id} or \grammarterm{type-id} denotes an array type), |
| 5029 | +the \grammarterm{new-expression} yields a prvalue of type ``pointer to \tcode{T}'' |
| 5030 | +that points to the initial element (if any) of the array. |
| 5031 | +Otherwise, let \tcode{T} be the allocated type; |
| 5032 | +the \grammarterm{new-expression} |
| 5033 | +is a prvalue of type ``pointer to T'' |
| 5034 | +that points to the object created. |
| 5035 | +\begin{note} |
| 5036 | +Both \tcode{\keyword{new} \keyword{int}} and \tcode{\keyword{new} \keyword{int}[10]} have type \tcode{\keyword{int}*} and |
| 5037 | +the type of \tcode{\keyword{new} \keyword{int}[i][10]} is \tcode{\keyword{int} (*)[10]}. |
| 5038 | +\end{note} |
| 5039 | + |
5036 | 5040 | \pnum
|
5037 | 5041 | A \grammarterm{new-expression} may obtain storage for the object by calling an
|
5038 | 5042 | allocation function\iref{basic.stc.dynamic.allocation}. If
|
|
0 commit comments