Unexpected non-constant std::initializer_list

后端 未结 1 1696
情歌与酒
情歌与酒 2021-01-02 10:18

I was toying a little bit with the indices trick to see where I could go to with and came across a strange error... First, the plain not-so-old indices:

temp         


        
1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 11:15

    From: the man himself http://www.stroustrup.com/sac10-constexpr.pdf

    Specifically: its return type, and the types of its parameters (if any), are literal types (see x2.2). For concreteness, literal types include bool, int, or double; its body is a compound statement of the form { return expr; } where expr is such that if arbitrary constant expressions of appropriate types are substituted for the parameters in expr, then the resulting expression is a constant expression as defined in introductory paragraph of x2. The expression expr is called a potential constant expression.

    0 讨论(0)
提交回复
热议问题