Templates and STL

前端 未结 6 1794
情歌与酒
情歌与酒 2021-01-05 18:31

The following code represents a container based on std::vector

template 
struct TList
{
    typedef std::vector  Type;
};


         


        
6条回答
  •  清歌不尽
    2021-01-05 18:47

    well, you can hack it up with a macro:

    template  >
    struct TList
    {
        typedef stl_container Type;
    };
    
    #define TLIST(T, C) TList >
    
    TList foo;
    TList > bar;
    TLIST(int, std::list) baz;
    

提交回复
热议问题