|
1141 | 1141 | \indextext{scope name hiding and}%
|
1142 | 1142 | \indextext{name hiding}%
|
1143 | 1143 | \indextext{hiding|see{name hiding}}%
|
1144 |
| -A name can be hidden by an explicit declaration of that same name in a |
1145 |
| -nested declarative region or derived class\iref{class.member.lookup}. |
| 1144 | +A declaration of a name in a nested declarative region |
| 1145 | +hides a declaration of the same name in an enclosing declarative region; |
| 1146 | +see \ref{basic.scope.declarative} and \ref{basic.lookup.unqual}. |
1146 | 1147 |
|
1147 | 1148 | \pnum
|
1148 | 1149 | \indextext{name hiding}%
|
1149 |
| -A class name\iref{class.name} or enumeration name\iref{dcl.enum} can |
1150 |
| -be hidden by the name of a variable, data member, function, or enumerator declared in |
1151 |
| -the same scope. If a class or enumeration name and a variable, data member, function, |
1152 |
| -or enumerator are declared in the same scope (in any order) with the |
1153 |
| -same name, the class or enumeration name is hidden wherever the variable, data member, |
| 1150 | +If a class name\iref{class.name} or enumeration name\iref{dcl.enum} and |
| 1151 | +a variable, data member, function, or enumerator |
| 1152 | +are declared in the same declarative region (in any order) with the |
| 1153 | +same name (excluding declarations made visible |
| 1154 | +via \grammarterm{using-directive}{s}\iref{basic.lookup.unqual}), |
| 1155 | +the class or enumeration name is hidden wherever the variable, data member, |
1154 | 1156 | function, or enumerator name is visible.
|
1155 | 1157 |
|
1156 | 1158 | \pnum
|
|
2470 | 2472 | \item it is a cv-qualified\iref{basic.type.qualifier} version of a
|
2471 | 2473 | type that has linkage.
|
2472 | 2474 | \end{itemize}
|
2473 |
| -A type without linkage shall not be used as the type of a variable or |
2474 |
| -function with external linkage unless |
2475 |
| -\begin{itemize} |
2476 |
| -\item the entity has C language linkage\iref{dcl.link}, or |
2477 |
| - |
2478 |
| -\item the entity is not odr-used\iref{basic.def.odr} or is defined in |
2479 |
| -the same translation unit. |
2480 |
| -\end{itemize} |
2481 | 2475 | \begin{note}
|
2482 | 2476 | In other words, a type without linkage contains a class or enumeration that
|
2483 |
| -cannot be named outside its translation unit. An entity with external linkage declared |
2484 |
| -using such a type could not correspond to any other entity in another translation unit |
2485 |
| -of the program and thus must be defined in the |
2486 |
| -translation unit if it is odr-used. Also note that classes with linkage may contain members |
2487 |
| -whose types do not have linkage, and that typedef names are ignored in the determination |
| 2477 | +cannot be named outside its translation unit. |
| 2478 | +Classes with linkage may contain members |
| 2479 | +whose types do not have linkage. |
| 2480 | +Typedef names are ignored in the determination |
2488 | 2481 | of whether a type has linkage.
|
2489 | 2482 | \end{note}
|
2490 | 2483 |
|
|
2501 | 2494 | A a = { 1 };
|
2502 | 2495 | B<A> ba; // declares \tcode{B<A>::g(A)} and \tcode{B<A>::h(A)}
|
2503 | 2496 | ba.g(a); // OK
|
2504 |
| - ba.h(a); // error: \tcode{B<A>::h(A) not defined in the translation unit} |
| 2497 | + ba.h(a); // error: \tcode{B<A>::h(A)} not defined; \tcode{A} cannot be named in another translation unit |
2505 | 2498 | i(ba, a); // OK
|
2506 | 2499 | }
|
2507 | 2500 | \end{codeblock}
|
|
3236 | 3229 | class\iref{class.free}.
|
3237 | 3230 |
|
3238 | 3231 | \pnum
|
3239 |
| -Any allocation and/or deallocation functions defined in a \Cpp{} program, |
3240 |
| -including the default versions in the library, shall conform to the |
3241 |
| -semantics specified in~\ref{basic.stc.dynamic.allocation} |
3242 |
| -and~\ref{basic.stc.dynamic.deallocation}. |
| 3232 | +If the behavior of an allocation or deallocation function |
| 3233 | +does not satisfy the semantic constraints |
| 3234 | +specified in~\ref{basic.stc.dynamic.allocation} |
| 3235 | +and~\ref{basic.stc.dynamic.deallocation}, |
| 3236 | +the behavior is undefined. |
3243 | 3237 |
|
3244 | 3238 | \rSec4[basic.stc.dynamic.allocation]{Allocation functions}
|
3245 | 3239 |
|
|
3251 | 3245 | global scope. The return type shall be \tcode{void*}. The first
|
3252 | 3246 | parameter shall have type \tcode{std::size_t}\iref{support.types}. The
|
3253 | 3247 | first parameter shall not have an associated default
|
3254 |
| -argument\iref{dcl.fct.default}. The value of the first parameter shall |
3255 |
| -be interpreted as the requested size of the allocation. An allocation |
| 3248 | +argument\iref{dcl.fct.default}. The value of the first parameter |
| 3249 | +is interpreted as the requested size of the allocation. An allocation |
3256 | 3250 | function can be a function template. Such a template shall declare its
|
3257 | 3251 | return type and first parameter as specified above (that is, template
|
3258 | 3252 | parameter types shall not be used in the return type and first parameter
|
3259 | 3253 | type). Template allocation functions shall have two or more parameters.
|
3260 | 3254 |
|
3261 | 3255 | \pnum
|
3262 |
| -The allocation function attempts to allocate the requested amount of |
3263 |
| -storage. If it is successful, it shall return the address of the start |
3264 |
| -of a block of storage whose length in bytes shall be at least as large |
3265 |
| -as the requested size. There are no constraints on the contents of the |
3266 |
| -allocated storage on return from the allocation function. The order, |
| 3256 | +An allocation function attempts to allocate the requested amount of |
| 3257 | +storage. If it is successful, it returns the address of the start |
| 3258 | +of a block of storage whose length in bytes is at least as large |
| 3259 | +as the requested size. |
| 3260 | +The order, |
3267 | 3261 | contiguity, and initial value of storage allocated by successive calls
|
3268 |
| -to an allocation function are unspecified. The pointer returned shall be |
| 3262 | +to an allocation function are unspecified. |
| 3263 | +For an allocation function other than |
| 3264 | +a reserved placement allocation function\iref{new.delete.placement}, |
| 3265 | +the pointer returned is |
3269 | 3266 | suitably aligned so that it can be converted to a pointer to any
|
3270 | 3267 | suitable complete object type\iref{new.delete.single}
|
3271 | 3268 | and then used to access the object or array in the
|
3272 | 3269 | storage allocated (until the storage is explicitly deallocated by a call
|
3273 | 3270 | to a corresponding deallocation function). Even if the size of the space
|
3274 | 3271 | requested is zero, the request can fail. If the request succeeds, the
|
3275 |
| -value returned shall be a non-null pointer value\iref{conv.ptr} |
| 3272 | +value returned by a replaceable allocation function |
| 3273 | +is a non-null pointer value\iref{conv.ptr} |
3276 | 3274 | \tcode{p0} different from any previously returned value \tcode{p1},
|
3277 |
| -unless that value \tcode{p1} was subsequently passed to an |
3278 |
| -\tcode{operator} \tcode{delete}. |
| 3275 | +unless that value \tcode{p1} was subsequently passed to a |
| 3276 | +replaceable deallocation function. |
3279 | 3277 | Furthermore, for the library allocation functions
|
3280 | 3278 | in~\ref{new.delete.single} and~\ref{new.delete.array},
|
3281 |
| -\tcode{p0} shall represent the address of a block of storage disjoint from the storage |
| 3279 | +\tcode{p0} represents the address of a block of storage disjoint from the storage |
3282 | 3280 | for any other object accessible to the caller.
|
3283 | 3281 | The effect of indirecting through a pointer
|
3284 |
| -returned as a request for zero size is undefined.\footnote{The intent is |
| 3282 | +returned from a request for zero size is undefined.\footnote{The intent is |
3285 | 3283 | to have \tcode{operator new()} implementable by
|
3286 | 3284 | calling \tcode{std::malloc()} or \tcode{std::calloc()}, so the rules are
|
3287 | 3285 | substantially the same. \Cpp{} differs from C in requiring a zero request
|
|
3295 | 3293 | A program-supplied allocation function can obtain the address of the
|
3296 | 3294 | currently installed \tcode{new_handler} using the
|
3297 | 3295 | \tcode{std::get_new_handler} function\iref{set.new.handler}. \end{note}
|
3298 |
| -If an allocation function that has a non-throwing |
| 3296 | +An allocation function that has a non-throwing |
3299 | 3297 | exception specification\iref{except.spec}
|
3300 |
| -fails to allocate storage, it shall return a null pointer. Any other |
3301 |
| -allocation function that fails to allocate storage shall indicate |
3302 |
| -failure only by throwing an exception\iref{except.throw} of a type |
| 3298 | +indicates failure by returning |
| 3299 | +a null pointer value. |
| 3300 | +Any other allocation function |
| 3301 | +never returns a null pointer value and |
| 3302 | +indicates failure only by throwing an exception\iref{except.throw} of a type |
3303 | 3303 | that would match a handler\iref{except.handle} of type
|
3304 | 3304 | \tcode{std::bad_alloc}\iref{bad.alloc}.
|
3305 | 3305 |
|
|
0 commit comments