This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 182. Ambiguous references to size_t

Section: 16 [library] Status: CD1 Submitter: Al Stevens Opened: 1999-08-15 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [library].

View all other issues in [library].

View all issues with CD1 status.

Discussion:

Many references to `size_t` throughout the document omit the `std::` namespace qualification.

For example, 16.4.5.6 [replacement.functions] paragraph 2:

>      operator new(size_t)
>      operator new(size_t, const std::nothrow_t&)
>      operator new[](size_t)
>      operator new[](size_t, const std::nothrow_t&)

Proposed resolution:

In 16.4.5.6 [replacement.functions] paragraph 2: replace:

> `- operator new(size_t)
> - operator new(size_t, const std::nothrow_t&)
> - operator new[](size_t)
> - operator new[](size_t, const std::nothrow_t&)`

by:

>     - operator new(std::size_t)
>     - operator new(std::size_t, const std::nothrow_t&)
>     - operator new[](std::size_t)
>     - operator new[](std::size_t, const std::nothrow_t&)

In [lib.allocator.requirements] 20.1.5, paragraph 4: replace:

> The typedef members pointer, const_pointer, size_type, and difference_type are required to be T*, T const*, size_t, and ptrdiff_t, respectively.

by:

> The typedef members pointer, const_pointer, size_type, and difference_type are required to be T*, T const*, std::size_t, and std::ptrdiff_t, respectively.

In [lib.allocator.members] 20.4.1.1, paragraphs 3 and 6: replace:

> 3 Notes: Uses ::operator new(size_t) (18.4.1).

> 6 Note: the storage is obtained by calling ::operator new(size_t), but it is unspecified when or how often this function is called. The use of hint is unspecified, but intended as an aid to locality if an implementation so desires.

by:

> 3 Notes: Uses ::operator new(std::size_t) (18.4.1).

> 6 Note: the storage is obtained by calling ::operator new(std::size_t), but it is unspecified when or how often this function is called. The use of hint is unspecified, but intended as an aid to locality if an implementation so desires.

In [lib.char.traits.require] 21.1.1, paragraph 1: replace:

> In Table 37, X denotes a Traits class defining types and functions for the character container type CharT; c and d denote values of type CharT; p and q denote values of type const CharT*; s denotes a value of type CharT*; n, i and j denote values of type size_t; e and f denote values of type X::int_type; pos denotes a value of type X::pos_type; and state denotes a value of type X::state_type.

by:

> In Table 37, X denotes a Traits class defining types and functions for the character container type CharT; c and d denote values of type CharT; p and q denote values of type const CharT*; s denotes a value of type CharT*; n, i and j denote values of type std::size_t; e and f denote values of type X::int_type; pos denotes a value of type X::pos_type; and state denotes a value of type X::state_type.

In [lib.char.traits.require] 21.1.1, table 37: replace the return type of X::length(p): "size_t" by "std::size_t".

In [lib.std.iterator.tags] 24.3.3, paragraph 2: replace:
typedef ptrdiff_t difference_type;
by:
typedef std::ptrdiff_t difference_type;

In [lib.locale.ctype] 22.2.1.1 put namespace std { ...} around the declaration of template <class charT> class ctype.
In [lib.iterator.traits] 24.3.1, paragraph 2 put namespace std { ...} around the declaration of:
template<class Iterator> struct iterator_traits
template<class T> struct iterator_traits<T*>
template<class T> struct iterator_traits<const T*>

Rationale:

The LWG believes correcting names like `size_t` and `ptrdiff_t` to `std::size_t` and `std::ptrdiff_t` to be essentially editorial. There there can't be another size_t or ptrdiff_t meant anyway because, according to 16.4.5.3.5 [extern.types],

> For each type T from the Standard C library, the types ::T and std::T are reserved to the implementation and, when defined, ::T shall be identical to std::T.

The issue is treated as a Defect Report to make explicit the Project Editor's authority to make this change.

[Post-Tokyo: Nico Josuttis provided the above wording at the request of the LWG.]

[Toronto: This is tangentially related to issue 229, but only tangentially: the intent of this issue is to address use of the name `size_t` in contexts outside of namespace std, such as in the description of `::operator new`. The proposed changes should be reviewed to make sure they are correct.]

[pre-Copenhagen: Nico has reviewed the changes and believes them to be correct.]