我想知道为什么编译器不能容忍初始化浮点数一个const long double但允许使用long double literal初始化?我们不是在前者失去精确度吗?
float f {3.14L}; //compiles
const long double myConst {3.14};
float f{myConst}; // error: non-constant-expression cannot be narrowed from type 'long double' to 'float' in initializer list
Run Code Online (Sandbox Code Playgroud)