constexpr versus template, pow function

匆匆过客 提交于 2019-12-05 02:55:38

inline is nothing more than a hint for the compiler. It can do whatever it prefers. It exists compiler specific stuff like pragmas and __declspec to force on or off the inlining on a function.

May be the non const lvalue reference of the constexpr version interfers. You should just pass by value to a pow anyway.

It is not an error for a particular instantiation of a constexpr function template to not be really constexpr, as long as you don't attempt to use it in a context that requires a constant expression. Maybe your instantiated template is not constexpr.

To find out, do this:

constexpr double powtest = pow(2.0, 5);

If the compiler complains, you know there's something wrong.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!