我是否正确理解unsigned int{};
的含义为在下列上下文中对一个无名的临时unsigned int
进行零初始化?该示例在clang或gcc下无法工作,但在Visual Studio中可以编译通过:https://godbolt.org/z/LYWCCN
int ifun(int value) {
return value * 10;
}
unsigned int uifun(unsigned int value) {
return value * 10u;
}
int main() {
// does not work in gcc and clang
unsigned int{};
unsigned int ui = uifun(unsigned int{});
// works with all three compilers, also unsigned{}; works
int{};
int i = ifun(int{});
}