+= on a vector without boost

前端 未结 2 1713
后悔当初
后悔当初 2021-01-22 11:34

Is there any way to use the += operator with a vector without using boost or using a derivated class?

Eg.

somevector += 1, 2, 3, 4, 5, 6, 7;
2条回答
  •  佛祖请我去吃肉
    2021-01-22 12:03

    Not with syntax like that, no. But you could do something like this:

    int tmparray[] = {1, 2, 3, 4, 5, 6, 7};
    
    somevector.insert(somevector.end(), 
                      tmparray, 
                      tmparray + (sizeof(tmparray) / sizeof(tmparray[0])));
    

提交回复
热议问题