为何GCC在模板上下文对同一lambda生成不同类型?
GCC对lambda类型的模板处理异常问题
我研究有状态元编程已有一段时间,发现GCC存在一个奇怪的行为。代码如下:
#include <type_traits> // 移除模板声明即可编译通过 template <typename = void> void test() { // 将lambda替换为其他任意类型也可编译通过 using NonDependentStaticType = decltype([](){}); static_assert(std::is_same_v<NonDependentStaticType, NonDependentStaticType>); } int main() { test(); }
该代码在最新版Clang和MSVC中可正常编译,但在GCC中编译失败。我想确认:无论编译器如何处理默认lambda模板参数,static_assert都不应失败,这个观点是否正确?
更新:感谢@Jarod42提供简化代码示例。
内容的提问来源于stack exchange,提问作者Dmitry
相关产品推荐
相关产品推荐

