Topic: Container requirement for pointer typedef
Author: David Hunter <dhunter@lehman.com>
Date: 1999/11/30 Raw View
I've noticed that various implementations I've seen of the STL
portion of the standard library differ in whether they implement
typedef's for pointers to the contained items.
Is it required in the spec for a container to implement typedef's for
pointers to the contained type ie
typedef [stuff] pointer;
typedef [stuff] const_pointer;
so that I can write code like ( where T is a container type ):
T::pointer var;
or should I write something like
T::allocator_type::pointer var;
David Hunter
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: 1999/12/01 Raw View
David Hunter wrote:
>
> I've noticed that various implementations I've seen of the STL
> portion of the standard library differ in whether they implement
> typedef's for pointers to the contained items.
>
> Is it required in the spec for a container to implement typedef's for
> pointers to the contained type ie
>
> typedef [stuff] pointer;
> typedef [stuff] const_pointer;
>
> so that I can write code like ( where T is a container type ):
>
> T::pointer var;
>
> or should I write something like
>
> T::allocator_type::pointer var;
The typedefs required of every container are: value_type, reference,
const_reference, iterator, const_iterator, difference_type, and
size_type.
Reversible containers add: reverse_iterator, const_reverse_iterator
Associative containers add: key_type, key_compare, value_compare
All containers defined by the standard add: allocator_type
(user-defined containers needn't define it to meet the container
requirements)
deque, list, vector, map, multimap, set, and multiset add: pointer,
const_pointer
queue, priority_queue, and stack add: container_type
map and multimap add: mapped_type
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]