Plain Old Data (POD)
Kajanan told me about this. He correctly guessed what trivially_copyable
does.
A Plain Old Data (POD) structure is a scalar type or aggregate class that contains only PODs as members.
- NO user-defined constructors or destructors
- NO methods
Why is the concept of PODs important?
PODs guarantee that they are stored in contiguous memory (like a C struct).
Resources:
- https://en.wikipedia.org/wiki/Passive_data_structure
- https://www.educative.io/answers/what-are-plain-old-data-pod-types-in-cpp (WRONG with the example)
It’s basically a C Struct.
- Aggregate types with no user-defined constructors, destructors, or assignment operators.
- Can have data members and static members but no virtual functions.
- Memory layout is compatible with C structs.
- Ensures layout compatibility with C and predictable initialization.
NOT a POD
- because
name
is not a POD, it has has a constructor and destructor. So this ISN’T a POD.
Difference between POD and a C Struct?
I think they’re the same…?