
貌似不能直接~unordered_map<int,int>()这样做
1 hyq 2017-03-22 13:55:10 +08:00 boost::unorderd_map<int, int> *mymap = (boost::unorderd_map<int, int> *)malloc(sizeof(boost::unorderd_map<int, int>)); mymap->boost::unorderd_map<int, int>(); // 手动调用构造函数 // do something mymap->~boost::unordered_map<int, int>(); // 手动析构 free(mymap); |
2 hyq 2017-03-22 13:55:52 +08:00 刚才写错了,函数名不需要命名空间 boost::unorderd_map<int, int> *mymap = (boost::unorderd_map<int, int> *)malloc(sizeof(boost::unorderd_map<int, int>)); mymap->unorderd_map<int, int>(); // 手动调用构造函数 // do something mymap->~unordered_map<int, int>(); // 手动析构 free(mymap); |
3 alqaz 2017-03-22 15:27:32 +08:00 试下 mymap->~unordered_map(); 还有,我想说的是,你对 map 调用 malloc()然后强转,然后对 map do something,后面居然还要手动调用析构函数,小伙子,你思想很危险啊。 |