Creating a type alias for a templated class

后端 未结 3 1746
小鲜肉
小鲜肉 2020-12-31 16:35

Instead of using

std::vector ObjectArray;


I would like it to be

MyArray ObjectArray;

3条回答
  •  醉梦人生
    2020-12-31 17:11

    Another way:

    #include 
    
    template 
    struct MyArray
        :std::vector
    {
    };
    
    void func()
    {
        MyArray my;
    
        my.push_back(5);
    
        MyArray::iterator i;
    }
    

    Compiles for me, but you may find that some things available in vector<> need to be "pulled up" into MyArray.

提交回复
热议问题