Whyever **not** declare a function to be `constexpr`?

前端 未结 3 1134

Any function that consists of a return statement only could be declared constexpr and thus will allow to be evaluated at compile time if all arguments are

3条回答
  •  攒了一身酷
    2020-12-23 16:35

    If the function has side effects, you would not want to mark it constexpr. Example

    I can't get any unexpected results from that, actually it looks like gcc 4.5.1 just ignores constexpr

提交回复
热议问题