constexpr function parameters as template arguments

前端 未结 4 1141
谎友^
谎友^ 2020-11-30 07:43

I am playing around with some toy code using c++11 to figure out a bit more about how things work. During this I came across the following issue that simplifies down to:

4条回答
  •  天涯浪人
    2020-11-30 08:01

    The compiler does not know if x and y are always available at compile time as constant values (expression), and what more, C++11/14 does not support constexpr function parameter, so there's no way x and y can be used as parameter for the template add<> in addFunc.

提交回复
热议问题