有人知道为什么编译时没有警告吗
int main()
{
const int i = 1024;
std::initializer_list<size_t> i_l = { i }; // no warning
return 0;
}
但不
int main()
{
const int i = pow(2,10);
std::initializer_list<size_t> i_l = { i }; // warning
return 0;
}
警告:
non-constant-expression cannot be narrowed from type 'int' to 'unsigned long' in initializer list [-Wc++11-narrowing]
std::initializer_list<size_t> i_l = { i }; i_l = i_l; // warning