Your code causes undefined behavior, since standard containers like vector cannot contain incomplete types, and tnode is an incomplete type in the structure definition. According to the C ++ 11 standard, 17.6.4.8p2:
effects are undefined in the following cases: [...] if the incomplete type (3.9) is used as a template argument when creating an instance of a template component, unless this is specifically permitted for this component.
The Boost.Container library provides alternative containers (including vector ) that may contain incomplete types. Recursive data types, such as the one you want, are provided as a use case.
The following will work with Boost.Container:
source share