std::map 是通过引用、按值获取分配器还是纯粹将其用作类型?

Does a std::map take an allocator by reference, by value or use it purely as a type?

std::map 将 Allocator 作为构造函数中的参数时,它通过引用从其 class 模板参数中获取的类型来获取它:

explicit map(const Allocator& alloc);

它是将此引用存储在对象中,还是获取一个副本(按值存储),或者两者都不做,仅通过模板参数将其用作类型?你是如何确定的?

分配器已复制到映射中。 std::map 没有具体说明它的作用所以我们回到 [container.requirements.general]/8 其中指出:

[...]All other constructors for these container types take a const allocator_type& argument. [ Note: If an invocation of a constructor uses the default value of an optional allocator argument, then the Allocator type must support value-initialization. — end note ] A copy of this allocator is used for any memory allocation and element construction performed, by these constructors and by all member functions, during the lifetime of each container object or until the allocator is replaced.[...]

强调我的