Why do templates allow constexpr function members with non-constexpr constructors?

前端 未结 2 1529
有刺的猬
有刺的猬 2021-01-22 05:23

Using C++14. Why will this compile:

template
constexpr bool foo()
{
    std::array arr;
    return true;
}

but

2条回答
  •  被撕碎了的回忆
    2021-01-22 05:50

    They don't. Your test is flawed.

    The problem is not detected until you actually attempt to instantiate the broken function template.

提交回复
热议问题