Why is constexpr with std::forward_as_tuple not working? [duplicate]

允我心安 提交于 2020-01-05 07:11:27

问题


Why is the following not compiling? This is somehow counter-intuitive (not to say constexpr concepts are confusing):

#include <tuple>

int main() {
    constexpr const int a   = 0;
    static_assert(a == 0, "Wups");
    constexpr auto t2 = std::forward_as_tuple(a, a);
}

LIVE I assumed that a is a compile-time constant expression which is clearly the case as I can use it in static_assert.

Background: I wanted to continue with constexpr tuple of reference to feed to other constexpr functions to do some compile-time computations

来源:https://stackoverflow.com/questions/59563997/why-is-constexpr-with-stdforward-as-tuple-not-working

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