美文网首页
★17.关于无序容器

★17.关于无序容器

作者: iDragonfly | 来源:发表于2017-06-30 22:19 被阅读0次

    简单示例

    #include <unordered_map>
    
    class A {
    public:
        std::string s;
    
        static size_t hashFun(const A & a) {
            return std::hash<std::string>()(a.s);
        }
    
        bool operator==(const A & a) const {
            // do something
            return true;
        }
    };
    
    
    int main() {
        std::unordered_map<A, std::string, decltype(&A::hashFun)> a(10, A::hashFun);
        return system("pause");
    }
    

    相关文章

      网友评论

          本文标题:★17.关于无序容器

          本文链接:https://www.haomeiwen.com/subject/puoicxtx.html