Initialization of std::vector with a list of consecutive unsigned integers

前端 未结 5 1421
抹茶落季
抹茶落季 2020-12-16 03:45

I want to use a special method to initialize a std::vector which is described in a C++ book I use as a reference (the German book \'Der C++

5条回答
  •  囚心锁ツ
    2020-12-16 04:26

    No, that variant does not exist. The second constructor initializes a vector from two iterators that point into another sequence.

    Here is an example of the "two-iterator" constructor in action:

    int fill_data[4] = { 1, 2, 3, 4 };
    std::vector v(fill_data, fill_data + 4);
    

提交回复
热议问题