现在我有一个C++函数
void F( std::array<int,3> x )
{
//...
}
Run Code Online (Sandbox Code Playgroud)
我希望参数'x'可以有一个默认值,我该怎么做?
如果不是函数参数,我可以简单地使用
std::array<int,3> x = {1,2,3};
Run Code Online (Sandbox Code Playgroud)
但对于函数参数,代码
void F( std::array<int,3> x = {1,2,3} )
{
//...
}
Run Code Online (Sandbox Code Playgroud)
会使编译错误.
我在MSVC 2012中测试,并得到错误C2143,C2059,C2447.还有g ++ 4.6.3中的错误
有没有办法让它有一个默认值?
谢谢.