【发布时间】:2013-07-28 09:04:36
【问题描述】:
我使用过的大多数 C++ 编译器都接受以下内容
#include <map>
struct A;
struct B
{
typedef std::map<int,A>::iterator iterator;
std::map<int,A> test;
};
struct A
{
};
int main()
{
return 0;
}
然而,Apple clang 4.0 编译时使用
clang++ test.cpp -o test -std=c++11 -stdlib=libc++
产生一组错误,暗示 A 必须是完整类型,然后才能使用 std::map。这是 map 的 libc++ 实现中的缺陷、C++11 强加的新要求还是我的错误假设?
【问题讨论】:
-
更新:上面的代码在 clang++-3.8.0 [删除
-stdlib=libc++] 后编译得很好。