C++11 constexpr function's argument passed in template argument

后端 未结 4 1180
深忆病人
深忆病人 2020-12-17 14:13

This used to work some weeks ago:

template 
T            tfunc()
{
    return t + 10;
}

template 
constexpr T               


        
4条回答
  •  佛祖请我去吃肉
    2020-12-17 14:58

    Looks like it should give an error - it has no way of knowing that you passed in a constant value as t to func.

    More generally, you can't use runtime values as template arguments. Templates are inherently a compile-time construct.

提交回复
热议问题