Topic: allocator question
Author: Martin von Loewis <loewis@informatik.hu-berlin.de>
Date: 1998/09/18 Raw View
Terence Kelling <kelling@arlut.utexas.edu> writes:
> Can anyone tell me what the standard says the interface should be for
> the class std::allocator?
The std::allocator *template* is defined in 20.4.1
[lib.default.alloc]. I copy the interface below
>namespace std{
> template <class T>
> class allocator {
> public:
> typedef size_t size_type;
> typedef ptrdiff_t difference_type;
> typedef T* pointer;
> typedef const T* const_pointer;
> typedef T& reference;
> typedef const T& const_reference;
> typedef T value_type;
> template <class U> struct rebind {
> typedef allocator<U> other;
> };
> allocator() throw();
> allocator(const allocator&) throw();
> template <class U> allocator(const allocator<U>&) throw();
> ~allocator() throw();
> pointer address(reference x) const;
> const_pointer address(const_reference x) const;
> pointer allocate( size_type, allocator<void>::const_pointer hint = 0);
> void deallocate(pointer p, size_type n); size_type max_size()
> const throw();
> void construct(pointer p, const T& val); void destroy(pointer p);
> };
>}
There is also a specialization for void.
Hope this helps,
Martin
[ 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: Terence Kelling <kelling@arlut.utexas.edu>
Date: 1998/09/17 Raw View
Can anyone tell me what the standard says the interface should be for
the class std::allocator?
I am trying to compile a program using both MSVC and g++ and they
provide different definitions for allocator's methods for allocation and
deallocation. Furthermore, upon looking into SGI's implementation of
the STL, they use a different default memory allocation scheme than that
provided by allocator and do not define any of the typdefs that are
associated with it. In their header files, they say that allocator has
been depreciated. Is that just for their implementation, or did the
standard change in regards to that?
Thanks,
Terence Kelling
[ 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 ]