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


沒有留言:

張貼留言

202501 Debian USB LAN Card Bridge

 202501 Debian USB LAN Card Bridge ChatGPT Question I have a machine running debian 12 with a LAN port using a cable to connect to my office...