【发布时间】:2021-09-01 12:28:32
【问题描述】:
据我了解,以下程序应该可以在 C++20 模式下运行:
#include <vector>
struct B{ int a0, a1; };
int main()
{
std::vector<B> bs;
bs.emplace_back( 0, 0 );
}
在 Visual Studio 2019 和 gcc 11 中确实如此。但在产生错误的 clang 12 中却没有:
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/bits/alloc_traits.h:514:4: error: no matching function for call to 'construct_at'
std::construct_at(__p, std::forward<_Args>(__args)...);
^~~~~~~~~~~~~~~~~
在线编译器中:https://gcc.godbolt.org/z/GzccTWc5z
这是因为 clang 还不完全支持 C++20 吗?
【问题讨论】:
标签: c++ clang c++20 emplace aggregate-initialization