Can a string literal be subscripted in a constant expression?

前端 未结 2 1574
误落风尘
误落风尘 2020-12-06 05:22

This is valid, because a constexpr expression is allowed to take the value of \"a glvalue of literal type that refers to a non-volatile object defined with cons

2条回答
  •  再見小時候
    2020-12-06 05:37

    The intent is that this works and the paragraphs that state when an lvalue to rvalue conversion is valid will be amended with a note that states that an lvalue that refers to a subobject of a string literal is a constant integer object initialized with a constant expression (which is described as one of the allowed cases) in a post-C++11 draft.

    Your comment about the use within the preprocessor looks interesting but I'm unsure whether that is intended to work. I hear about this the first time at all.

提交回复
热议问题