引用类型可以用作STL映射中的键类型吗 [英] Can a reference type be used as the key type in an STL map
本文介绍了引用类型可以用作STL映射中的键类型吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以构造一个 std :: map
,其中键类型是引用类型,例如 Foo&
,如果没有,为什么不呢?
Can I construct an std::map
where the key type is a reference type, e.g. Foo &
and if not, why not?
推荐答案
C ++标准23.1.2 / 7 key_type
应该是可分配的。引用类型不是。
According to C++ Standard 23.1.2/7 key_type
should be assignable. Reference type is not.
这篇关于引用类型可以用作STL映射中的键类型吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文