J
John Harrison
If you specify an allocator in an STL container is it a requirement that
the allocator allocates object of the right type, or can you assume that
the container will rebind the allocator to the correct type?
For example I tried the following code which uses a 'wrong' allocator and
was slightly surrised to find it compiles on the three compilers I tried
it on
#include <vector>
#include <memory>
int main()
{
std::vector<int, std::allocator<double> > vec;
vec.push_back(1);
}
john
the allocator allocates object of the right type, or can you assume that
the container will rebind the allocator to the correct type?
For example I tried the following code which uses a 'wrong' allocator and
was slightly surrised to find it compiles on the three compilers I tried
it on
#include <vector>
#include <memory>
int main()
{
std::vector<int, std::allocator<double> > vec;
vec.push_back(1);
}
john