vector of incomplete type UB still?

Hi,
i read this article https://www.drdobbs.com/the-standard-librarian-containers-of-inc/184403814
that explains why its undefined behavior to instantiate a STL container of an incomplete type. However i noticed the article is from 2002 and in the end of it he explained that this might (or should) change for certain containers (like vector) in the future.

Just wondering if anyone know whether or not its still undefined behavior to instantiate a vector of an incomplete type in any of the modern c++ versions (11, 14, 17, or 20)?

My main reason for asking this is because i need to make a struct to represent a tree-like structure and i'd like to just be able to do something like this:
1
2
3
4
5
struct Node
{
  int SomeData;
  std::vector<Node> Nodes;
}


without having to use pointers or references (because big boys only use value semantics)
Last edited on
So i think i've found the answer here https://en.cppreference.com/w/cpp/container/vector
This container (but not its members) can be instantiated with an incomplete element type if the allocator satisfies the allocator completeness requirements.


so i guess its allowed since c++17
Last edited on
Topic archived. No new replies allowed.