Passing constexpr objects around

大憨熊 提交于 2019-11-27 09:45:53

The reason is that inside a constexpr function, parameters aren't constant expressions, regardless of whether the arguments are. You can call constexpr functions inside others, but the parameters of a constexpr function aren't constexpr inside, making any function call (even to constexpr functions) not a constant expression - inside.

const auto nOpen = numOpen( str );

Suffices. Only once you view the call from outside the constexpr-ness of the expressions inside is verified, deciding whether the whole call is constexpr or not.

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