This code:
class Foo {
std::unordered_map x;
};
gives me an error:
/usr/include/c++/4.7/bits/st
The C++ standard specifies for the various smart pointers that the template parameter is allowed to be an incomplete type.
This information is not given for container types. Because it is unspecified, an implementation is allowed to accept an incomplete type for one container class template and not another, and still be conformant.
To make your code portable, avoid making containers of any type before the type is completed.
Formally, this constraint is found in the following rule (17.6.4.8) which applies to your code:
In certain cases (replacement functions, handler functions, operations on types used to instantiate standard library template components), the C++ standard library depends on components supplied by a C++ program. If these components do not meet their requirements, the Standard places no requirements on the implementation.
In particular, the effects are undefined in the following cases:
...
- if an incomplete type is used as a template argument when instantiating a template component, unless specifically allowed for that component.