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


沒有留言:

張貼留言

2007 to 2023 HP and Dell Servers Comparison

  HP Gen5 to Gen11  using ChatGPT HP ProLiant Gen Active Years CPU Socket Popular HP CPUs Cores Base Clock Max RAM Capacity Comparable Dell ...