Concatenating C++ iterator ranges into a const vector member variable at construction time

后端 未结 5 1353
情歌与酒
情歌与酒 2020-12-19 06:42

I have a class X, which I provide a snippet of here:

class X {
  public:
    template 
    X(Iter begin, Iter end) : mVec(begin, end) {}         


        
5条回答
  •  离开以前
    2020-12-19 07:11

    Your static method might not be as bad as you think, depending on the optimization your compiler does. And in C++0x, move constructors will remove any copying that is currently taking place.

    In the meantime go with a wrapper iterator. The code is not likely to be as bad as the thread avakar links to, since you only need to implement an input iterator.

提交回复
热议问题