【发布时间】:2017-11-13 02:43:39
【问题描述】:
我知道这就像打开潘多拉魔盒,但它并没有停止困扰我。考虑一个简单的例子:
#include <type_traits>
template <auto>
struct Foo: std::false_type { };
template <>
struct Foo<[](){return 1;}()>:std::true_type { };
int main() {
static_assert(Foo<1>::value);
}
我知道不能在未评估的上下文中声明 lambda,但显然这里不是这种情况。更奇怪的是 clang 5.0.0(我猜,它首先部分支持 constexpr lambda)does compile it。
这是编译器错误还是 C++17 允许这样做?
【问题讨论】:
标签: c++ templates language-lawyer c++17