Consider the following code:
#include <map>
#include <iostream>
#include <string>
class MyAlloc : public std::allocator<std::pair<const int, std::string>>
{
public:
MyAlloc()
{
std::cout << "my alloc ctor" << std::endl;
}
};
int main()
{
std::map<int, std::string, std::less<int>, MyAlloc> ms;
ms.insert(std::make_pair(2, "hi"));
std::cout << ms[1] << std::endl;
return 0;
}
I've created my allocator to fit the default one. But I see my allocator not been used, not even constructed.
when I'm using a debugger I can see the map is using the default std::allocator.
Is there any problem with my allocator?