Pointers as keys in map C++ STL

后端 未结 5 766
误落风尘
误落风尘 2020-12-08 06:17

I have a question on how pointers to a custom object are handled when used as Keys in an map. More specifically if I define

std::map< CustomClass*, int &         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-08 07:06

    C++ standard provided specialisation of std::less for pointers, so yes you can safely use them as map keys etc.

提交回复
热议问题