Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/146.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 这里使用哪个std::vector构造函数?_C++_Stdvector - Fatal编程技术网

C++ 这里使用哪个std::vector构造函数?

C++ 这里使用哪个std::vector构造函数?,c++,stdvector,C++,Stdvector,我有一张代码图片(它来自): uint32\u t glfwExtensionCount=0; 常量字符**glfwExtensions; glfwExtensions=glfwGetRequiredInstanceExtensions(&glfwExtensionCount); 向量扩展(glfwExtensions,glfwExtensions+glfwExtensionCount);//这里使用哪个构造函数? 所有的东西都可以编译并工作,但我不知道向量构造函数中会发生什么。这是一个问题

我有一张代码图片(它来自):

uint32\u t glfwExtensionCount=0;
常量字符**glfwExtensions;
glfwExtensions=glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
向量扩展(glfwExtensions,glfwExtensions+glfwExtensionCount);//这里使用哪个构造函数?
所有的东西都可以编译并工作,但我不知道向量构造函数中会发生什么。

这是一个问题

template< class InputIt >
vector( InputIt first, InputIt last,
        const Allocator& alloc = Allocator() );
template
向量(先输入,后输入,
常量分配器&alloc=Allocator());
(#4英寸)。 它从一系列输入迭代器构造一个向量


C++迭代器设计为与指针兼容,即指针是有效的迭代器。

上述向量定义使用
范围
构造函数。问题是


迭代器从begin+1开始到最后一个位置,这就是为什么向量构造中省略了第一个元素。

我认为使用2个迭代器的迭代器(begin+end)为什么不使用调试器?走一步,你就坐在上面了!谢谢,当然是它的范围构造器。我现在明白了。
template< class InputIt >
vector( InputIt first, InputIt last,
        const Allocator& alloc = Allocator() );
template <class InputIterator>
  vector (InputIterator first, InputIterator last,
          const allocator_type& alloc = allocator_type());
int main() {
  int a[] = {1, 2, 3};
  vector<int> v(a + 1, a + 3);
  for (int x : v) {
    cout << x << endl;
  }
  return 0;
}
2
3