我看到一个函数,它接受一个std :: vector的引用,并且传递给它的参数让我感到困惑,因为发生了什么。它看起来像这样:在这个std :: vector构造函数中发生了什么?
void aFunction(const std::vector<int>& arg) { }
int main()
{
aFunction({ 5, 6, 4 }); // Curly brace initialisation? Converting constructor?
std::vector<int> arr({ 5, 6, 4 }); // Also here, I can't understand which of the constructors it's calling
return 0;
}
谢谢。
是如何初始化器列表从大括号列表中创建?它是初始化列表的一部分转换构造函数吗? – Zebrafish
谢谢。我永远不会停止学习这种语言。 – Zebrafish