C++ 为什么这个自定义分配器的析构函数在GCC/MSVS';s标准数据库

C++ 为什么这个自定义分配器的析构函数在GCC/MSVS';s标准数据库,c++,gcc,visual-c++,libstdc++,allocator,C++,Gcc,Visual C++,Libstdc++,Allocator,我一直在尝试编写一个简单的分配器,我编写了一个只记录其调用的最小分配器 当尝试在一些简单的std::vector操作中使用它时(至少在GCC和Visual Studio上),记录的行为看起来很直观,除了在请求所有分配之前以及最后调用析构函数外。在叮当声中,一切都按照预期工作,所以我不确定这是否只是一个编译器问题 假设这不是一个编译器错误,那么这个分配器缺少什么;或者我对分配器如何被调用的理解是错误的,而它只是好的 我有下面的代码作为一个现场演示 叮当作响的日志: DebugAllocat

我一直在尝试编写一个简单的分配器,我编写了一个只记录其调用的最小分配器

当尝试在一些简单的
std::vector
操作中使用它时(至少在GCC和Visual Studio上),记录的行为看起来很直观,除了在请求所有分配之前以及最后调用析构函数外。在叮当声中,一切都按照预期工作,所以我不确定这是否只是一个编译器问题

假设这不是一个编译器错误,那么这个分配器缺少什么;或者我对分配器如何被调用的理解是错误的,而它只是好的

我有下面的代码作为一个现场演示

叮当作响的日志:

    DebugAllocator::DebugAllocator(0)
        0xD886F0 = DebugAllocator::allocate(0, 1)
        0xD88710 = DebugAllocator::allocate(0, 2)
        DebugAllocator::deallocate(0, 0xD886F0, 1)
        0xD886F0 = DebugAllocator::allocate(0, 4)
        DebugAllocator::deallocate(0, 0xD88710, 2)
        0xD88730 = DebugAllocator::allocate(0, 8)
        DebugAllocator::deallocate(0, 0xD886F0, 4)
3, 1, 4, 1
        DebugAllocator::deallocate(0, 0xD88730, 8)
    DebugAllocator::~DebugAllocator(0)

模板
调试分配器(常量调试分配器和rhs)

不算作复制构造函数。因此,调用编译器生成的复制构造函数时,您没有观察到。

make\u unsigned\t。xcode对itTry进行了解释,包括
,这是一种C++14类型,如果您没有设置该标记,您可以将错误代码提取到大约20行代码中吗?
    DebugAllocator::DebugAllocator(0)
        0xF86C50 = DebugAllocator::allocate(0, 1)
    DebugAllocator::~DebugAllocator(0)
    0xF86CA0 = DebugAllocator::allocate(0, 2)
    DebugAllocator::deallocate(0, 0xF86C50, 1)
    0xF86C50 = DebugAllocator::allocate(0, 4)
    DebugAllocator::deallocate(0, 0xF86CA0, 2)
    0xF86C20 = DebugAllocator::allocate(0, 8)
    DebugAllocator::deallocate(0, 0xF86C50, 4)
3, 1, 4, 1
    DebugAllocator::deallocate(0, 0xF86C20, 8)
DebugAllocator::~DebugAllocator(0)
    DebugAllocator::DebugAllocator(0)
        0xD886F0 = DebugAllocator::allocate(0, 1)
        0xD88710 = DebugAllocator::allocate(0, 2)
        DebugAllocator::deallocate(0, 0xD886F0, 1)
        0xD886F0 = DebugAllocator::allocate(0, 4)
        DebugAllocator::deallocate(0, 0xD88710, 2)
        0xD88730 = DebugAllocator::allocate(0, 8)
        DebugAllocator::deallocate(0, 0xD886F0, 4)
3, 1, 4, 1
        DebugAllocator::deallocate(0, 0xD88730, 8)
    DebugAllocator::~DebugAllocator(0)
template<typename T_rhs>
DebugAllocator(const DebugAllocator<T_rhs>& rhs)