This paper addresses core issue 342 and implements a consistent terminology for "indirection through a pointer" throughout the core language section of the standard. As decided in Bloomington, the term "dereference" would be replaced by "indirection". This paper reflects the additional comments made during review at the Kona meeting. Due to the volume of the changes, they are presented as a separate paper as opposed to integrating them into the core issues list.
Here is the list of places that already uses "indirection":... The effect ofChange in 3.7.4.3 basic.stc.dynamic.safety paragraph 2:dereferencingindirecting through a pointer returned as a request for zero size is undefined. [ Footnote: ... ]
Change in 3.8 basic.life paragraph 5:
- the value returned by a call to the C++ standard library implementation of
::operator new(std::size_t)
; [ Footnote: This section does not impose restrictions ondereferencingindirection through pointers to memory not allocated by::operator new
. This maintains the ability of many C++ implementations to use binary libraries and components written in other languages. In particular, this applies to C binaries, becausedereferencingindirection through pointers to memory allocated bymalloc
std::malloc
is not restricted. ]- the result of taking the address of an object (or one of its subobjects) designated by an lvalue resulting from
dereferencingindirection through a safely-derived pointer value;- ...
... Indirection through suchChange in 4.11 conv.mem paragraph 2:Sucha pointermay be dereferencedis permitted but the resulting lvalue may only be used in limited ways, as described below. The program has undefined behavior if:
- ...
... Since the result has type "pointer to member ofChange in 5.2.9 expr.static.cast paragraph 12:D
of type cvT
",it can be dereferencedindirection through it with aD
object is valid. The result is the same as if indirecting through the pointer to member ofB
were dereferencedwith theB
subobject ofD
. The null member pointer value is converted to the null member pointer value of the destination type. [ Footnote: ... ]
... [ Note: although classChange in 5.3.1 expr.unary.op paragraph 1:B
need not contain the original member, the dynamic type of the objectonwith which indirection through the pointer to member is performeddereferencedmust contain the original member; see 5.5 expr.mptr.oper. -- end note ]
... [ Note: indirection through a pointer to an incomplete type (other than cvChange in 5.10 expr.eq paragraph 2:void
) is validcan be dereferenced. ... ]
... Otherwise they compare equal if and only if they would refer to the same member of the same most derived object (1.8 intro.object) or the same subobject ifChange in 7.5 dcl.link paragraph 8:they were dereferencedindirection with a hypothetical object of the associated class type were performed. [ Example: ... ]
[ Note: Because the language linkage is part of a function type, when indirecting through a pointer to C functionChange in 8.3.2 dcl.ref paragraph 5:(for example) is dereferenced, the function to whichitthe resulting lvalue refers is considered a C function. -- end note ]
... [ Note: in particular, a null reference cannot exist in a well-defined program, because the only way to create such a reference would be to bind it to the "object" obtained byDrafting note: The term "dereferenceable" is defined for iterators in 24.2.1p5. I see no need to eradicate that term. Therefore, 17.6.3.2 swappable.requirements p5, 23.2.3 sequence.reqmts p3, 23.2.4 associative.reqmts p8 and many more are unchanged.dereferencingindirection through a null pointer, which causes undefined behavior. As described in 9.6 class.bit, a reference cannot be bound directly to a bit-field. ]
Change in 17.6.3.5 allocator.requirements table 27:
aChange in 20.6.3.2 pointer.traits.functions:dereferenceablepointer of typeC*
through which indirection is valid
Returns: The first member function returns aChange in 20.6.4 util.dynamic.safety paragraph 10:dereferenceablepointer to r obtained by calling Ptr::pointer_to(r) through which indirection is valid; an instantiation of this function is ill-formed if Ptr does not have a matching pointer_to static member function. The second member function returnsstd::addressof(r)
.
... Hence indirection through a pointerChange in 20.6.12 specialized.algorithms paragraph 1:pointerslocated theremay not be dereferencedis undefined if the objectthey pointit points to was created by globaloperator new
and not previously declared reachable. [ Note: ... ]
... In all of the following algorithms, the formal template parameterChange in 22.4.5.1.2 locale.time.get.virtuals paragraph 11:ForwardIterator
is required to satisfy the requirements of a forward iterator (24.2.5 forward.iterators), and is required to have the property that no exceptions are thrown from increment, assignment, comparison, ordereference ofindirection through valid iterators. ...
Requires:Change in 23.4.4.2 map.cons paragraph 3:t
shallbe dereferenceablepoint to an object.
Requires: If the iterator'sChange in 23.4.5.2 multimap.cons paragraph 3:dereferenceindirection operator returns an lvalue or a const rvaluepair<key_type, mapped_type>
, then bothkey_type
andmapped_type
shall beCopyConstructible
.
Requires: If the iterator'sChange in 23.4.6.2 set.cons paragraph 4:dereferenceindirection operator returns an lvalue or a const rvaluepair<key_type, mapped_type>
, then bothkey_type
andmapped_type
shall beCopyConstructible
.
Requires If the iterator'sChange in 23.4.7.2 multiset.cons paragraph 3:dereferenceindirection operator returns an lvalue or a non-const rvalue, thenKey
shall beCopyConstructible
.
Requires If the iterator'sChange in 24.5.3 move.iterators paragraph 1:dereferenceindirection operator returns an lvalue or a non-const rvalue, thenKey
shall beCopyConstructible
.
Class templateChange the title of 28.12.1.3 re.regiter.derefmove_iterator
is an iterator adaptor with the same behavior as the underlying iterator except that itsdereferenceindirection operator implicitly converts the value returned by the underlying iterator'sdereferenceindirection operator to an rvalue reference. ....
Change the title of 28.12.2.3 re.tokiter.derefregex_iterator
dereferenceindirection
regex_token_iterator
dereferenceindirection