Are C++ recursive type definitions possible, in particular can I put a vector within the definition of T?

前端 未结 6 2098
轻奢々
轻奢々 2020-11-27 21:32

For one of my projects, what I really wanted to do was this (simplifying it to the bare minimum);

struct Move
{
    int src;
    int dst;
};

struct MoveTree         


        
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 21:52

    The C++ Standard (2003) clearly says that instantiating a standard container with an incomplete type, invokes undefined-behavior.

    The spec says in §17.4.3.6/2,

    In particular, the effects are undefined in the following cases:

    __ [..]
    — if an incomplete type (3.9) is used as a template argument when instantiating a template component.
    __ [..]

提交回复
热议问题