std::allocator construct/destroy vs. placement new/p->~T()

前端 未结 2 1614
庸人自扰
庸人自扰 2020-12-31 15:03

For a project of mine, I am writing some STL containers from scratch (I have my reasons). Since I am mimicking the functionality and interfaces of the STL so closely I am do

2条回答
  •  鱼传尺愫
    2020-12-31 15:33

    The allocator could add logging statements before and after construction/destruction, or any other side effects it cared to do.

    Of course the actual construction has to occur by calling placement new and the destructor, but it doesn't say in the rulebook that nothing else must happen in the construct/destroy functions

提交回复
热议问题