ARTICLE AD BOX
I was trying to check whether some types were POD (actually to see whether I could put them in a numpy array), and having discovered that std::is_pod is deprecated in C++20 thought I would try an alternative. The closest seemed to be std::is_standard_layout so I tried that, but was very surprised to discover that std::is_standard_layout_v<std::vector<double>> is true!
I then tested some other things to try and improve my understanding:
struct Test { double d; }; struct Test2 : Test { int i; }; struct Test3 : Test { int i; Test3(unsigned u) {} };I have summarized my findings below (Godbolt here):
| double | true | true | true |
| struct Test | true | true | true |
| struct Test2 | true | false | false |
| struct Test3 | false | false | false |
| std::array | true | true | true |
| std::vector | false | false | true |
| std::map | false | false | false |
Can someone explain why std::vector<double> is considered "standard layout" and what I should be using to check if a type is POD in C++20?
