Data Type

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:

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.
struct Employee  {
  char* name;
  int age; 
};

NOT a POD

struct Employee  {
  std::string name;
  int age; 
};
  • 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…?