3
std::pair
没有构造函数以初始化列表作为参数,但下面的代码如何编译?foo({1,2})如何为“void foo(对<int,int>)”工作
void foo(std::pair<int,int> pr)
{
}
void foo2(std::tuple<int,int,int> t)
{
}
void bar()
{
foo({1,2}); // compile OK
foo(std::pair<int,int>{1,2}); // compile OK
foo2(std::tuple<int,int,int>{1,2,3}); // compile OK
foo2({1,2,3}); // compile error
}
我使用clang3.7.0
”统一初始化与初始化程序列表无关。“我总是混淆{},非常感谢您的澄清! – camino