shorthand syntax for c++ map in map

后端 未结 2 1385
醉酒成梦
醉酒成梦 2020-12-06 01:34

If I have definitions like:

typedef map Foo_map_1
typedef map Foo_map_2
typedef map Foo_         


        
2条回答
  •  萌比男神i
    2020-12-06 02:22

    This is seems easy enough even for the limited C++ metaprogramming power:

    #include 
    #include 
    
    template
    struct NMap { typedef std::map::type> type; };
    
    template
    struct NMap<1, K, V> { typedef std::map type; };
    
    int main(int argc, const char *argv[]) {
        NMap<3, int, std::string>::type m;
        m[1][2][3] = "Test";
        return 0;
    }
    

提交回复
热议问题