STL custom allocators to manage different memory spaces

前端 未结 3 1492
野的像风
野的像风 2021-02-03 13:13

I would like to use different instances of an STL custom allocator class to manage different memory spaces, and then be able to specify an allocator instance to an STL container

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-03 13:52

    Perhaps you could code a set of allocator types which contains a static pointing to seperate memory spaces.

    Then, when the STL container constructs its allocator, the allocator uses the memory spaceassigned to that allocator.

    For simplicity, assume you want to use two memory spaces. Create two allocator types, one for each space. Pass the allocator type to the STL container constructors as required.

提交回复
热议问题