小编Dr.*_*pel的帖子

为什么重新构建的地图类型与原始地图类型不同?

考虑以下代码:

#include <iostream>
#include <typeinfo>
#include <map>


int main(int argc, const char* argv[]) {
    typedef std::map<int,float> testmap;
    typedef std::map<int,float> testmap2;
    typedef std::map<typename testmap::value_type::first_type, typename testmap::value_type::second_type> rebuiltMap;
    std::cout << "map samenes: " << std::is_same<testmap, rebuiltMap>::value << "\n";
    std::cout << "map samenes: " << std::is_same<testmap, testmap2>::value << "\n";
    std::cout << "original map type name " << typeid(testmap).name() << "\n";
    std::cout << "same     map type name " << typeid(testmap2).name() << "\n";
    std::cout << "rebuilt  map type name " << typeid(rebuiltMap).name() << "\n";
    std::cout …
Run Code Online (Sandbox Code Playgroud)

c++ types

6
推荐指数
2
解决办法
70
查看次数

标签 统计

c++ ×1

types ×1