2019年12月3日 星期二

c++ unordered_map





#include <iostream>
#include <unordered_map>

class A{
public:
    A(){}
    ~A(){}
    A(const A& a){std::cout<<"copy constructor"<<'\n';}
    void operator=(const A& a){std::cout<<"copy assignment"<<'\n';}
    A(const A&& a){std::cout<<"move constructor"<<'\n';}
    void operator=(const A&& a){std::cout<<"move assignment"<<'\n';}
};

void main() {
    std::unordered_map<int, A> m;
    for (int i=0; i<10; ++i) {
        m[i] = A();
        std::cout << i << ' ' << m.bucket_count() << '\n';
    }
    std::cout << m.size();
}



sadfsd


沒有留言:

張貼留言

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...