Topic: Allocators and STL containers
Author: James Kuyper <kuyper@wizard.net>
Date: 1997/10/30 Raw View
The standard definitions of the STL containers such as vector all start
out:
template <class T, class Allocator = allocator<T> >
class vector {
// details.
}
Section 23.2.4 paragraph 2 says that "A vector satisfies all of the
requirements of a container" and that vector<T,Allocator>::reference is
typedef'ed as Allocator::reference.
Table 66--Container requirements says that X::reference must be an
'lvalue of T'
I assume that this means that the following declaration would be an
error:
vector<int, allocator<double>> v;
1. How would this error manifest itself? Would it be diagnosed or
silent?
2. Would it be possible to write a container in such a way that
vector<T1,allocator<T2>> would work properly if there were appropriate
relationships between T2 and T1? What would those relationships have to
be?
3. Could the vector typedefs have been re-written to use
Allocator::rebind<T>::other instead of Allocator itself? If so, why
weren't they?
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/10/30 Raw View
James Kuyper <kuyper@wizard.net> writes:
> The standard definitions of the STL containers such as vector all start
> out:
[...]
> I assume that this means that the following declaration would be an
> error:
>
> vector<int, allocator<double>> v;
This will be discussed in Morristown in november. The answer
will certainly be in the final std, but I'll sumarise that
for you after the meeting.
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://www.pratique.fr/~bonnardv/
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]