在 2019/1/14 下午1:55, Liu Hao 写道:
> 在 2019/1/14 上午6:46, Maarten Verhage 写道:
> Your code is not valid. Clang++ rejects your snippet, too.
> 
> The array-to-pointer conversion from an array of `const char` is not
> allowed in a constant expression unless such an array is declared with
> `constexpr` [1]. Use `constexpr` in place of `const` will solve your
> problem.
> 
> [1] ISO/IEC WG21 N4762: 7.7 Constant expressions [expr.const], (2.7),
> (2.7.1), (2.7.3).  <http://eel.is/c++draft/expr.const#4.7>
> 
> 

Additionally, you can define your array as `static const`, which, after
the array-to-pointer conversion, also yields a constant expression [2].

[2] ISO/IEC WG21 N4762: 7.7 Constant expressions [expr.const], (6.2).
<http://eel.is/c++draft/expr.const#8.2>


-- 
Best regards,
LH_Mouse

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to