Title
pointer_traits should have a size_type member
Status
c++11
Section
[pointer.traits]
Submitter
INCITS

Created on 2010-08-25.00:00:00 last changed 153 months ago

Messages

Date: 2010-11-23.13:22:14

Proposed resolution:

In [allocator.requirements], Table 42, change two rows as follows:

X::size_type unsigned integral type a type that can represent the size of the largest object in the allocation model size_t make_unsigned<X::difference_type>::type
X::difference_type signed integral type a type that can represent the difference between any two pointers in the allocation model ptrdiff_t pointer_traits<X::pointer>::difference_type

In [allocator.traits.types], Change the definition of difference_type and size_type as follows:

typedef see below difference_type;

Type: Alloc::difference_type if such a type exists, else ptrdiff_t pointer_traits<pointer>::difference_type.

typedef see below size_type;

Type: Alloc::size_type if such a type exists, else size_t make_unsigned<difference_type>::type.

Date: 2010-11-23.13:22:14

[ Adopted at 2010-11 Batavia ]

Date: 2010-10-31.20:22:50

[ Post-Rapperswil, Pablo provided wording: ]

The original ballot comment reads simply: "pointer_traits should have a size_type for completeness." The additional details reveal, however, that the desire for a size_type is actually driven by the needs of allocator_traits. The allocator_traits template should get its default difference_type from pointer_traits but if it did, it should get its size_type from the same source. Unfortunately, there is no obvious meaning for size_type in pointer_traits.

Alisdair suggested, however, that the natural relationship between difference_type and size_type can be expressed simply by the std::make_unsigned<T> metafunction. Using this metafunction, we can easily define size_type for allocator_traits without artificially adding size_type to pointer_traits.

Moved to Tentatively Ready after 6 positive votes on c++std-lib.

Date: 2010-10-24.10:50:39

Addresses US-106

pointer_traits should have a size_type member for completeness.

Add typedef see below size_type; to the generic pointer_traits template and typedef size_t size_type; to pointer_traits<T*>. Use pointer_traits::size_type and pointer_traits::difference_type as the defaults for allocator_traits::size_type and allocator_traits::difference_type.

See Appendix 1 - Additional Details

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-11-23 13:22:14adminsetmessages: + msg5407
2010-11-14 13:10:57adminsetstatus: voting -> wp
2010-11-08 14:14:39adminsetstatus: ready -> voting
2010-10-21 19:47:27adminsetmessages: + msg4817
2010-10-21 19:47:27adminsetmessages: + msg4816
2010-08-25 00:00:00admincreate