我曾使用过的大多数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++
在使用std::map之前,必须保证A是一个完整的类型。如果出现一系列错误提示,则意味着这是libc++实现map时存在的缺陷,还是C++11提出的新要求,或者是我的假设有误?