引用类型可以用作 STL 映射中的键类型吗

2022-01-24 00:00:00 containers types c++ stl

Can I construct an std::map where the key type is a reference type, e.g. Foo & and if not, why not?

解决方案

According to C++ Standard 23.1.2/7 key_type should be assignable. Reference type is not.

相关文章