User defined literal arguments are not constexpr?

后端 未结 5 1090
余生分开走
余生分开走 2021-01-01 11:43

I\'m testing out user defined literals. I want to make _fac return the factorial of the number.

Having it call a constexpr function works,

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-01 12:16

    I may be wrong, but I think constexpr functions can also be called with non-constant arguments (in which case they don't give a constant expression and are evaluated at runtime). Which wouldn't work well with non-type template arguments.

提交回复
热议问题