Difference between const and constexpr arrays
问题 Why is there a difference between const and constexpr when used with arrays? int const xs[]{1, 2, 3}; constexpr int ys[]{1, 2, 3}; int as[xs[0]]; // error. int bs[ys[0]]; // fine. I would expect both xs[0] and ys[0] to be constant expressions but only the latter is treated as such. 回答1: A longer comment as community wiki. The expression xs[0] is defined in [expr.sub]/1 as *((xs)+(0)) . (See below for the parantheses.) One of the expressions shall have the type “pointer to T ” and the other