GCC使用static_assert诊断类型完整性. MSVC似乎不执行这种检查.如果它悄悄地将参数std::default_delete::operator()传递给delete,则将导致不确定的行为.这可能与您的观察结果相对应.它可能会起作用,但是除非得到文档的保证(作为非标准的C ++扩展),否则我不会使用它.GCC uses static_assert to diagnose the type completeness. MSVC seemingly does not perform such a check. If it silently passes a parameter of std::default_delete::operator() to delete, then, this causes undefined behavior. Which might correspond with your observation. It may work, but until it is guaranteed by the documentation (as a non-standard C++ extension), I wouldn't use it. 这篇关于编译器可以将隐式声明的虚拟析构函数的实现放在单个单独的转换单元中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-27 16:14