POD types in C++

Informally, a POD (“Plain Old Data”) type, is a type that looks and behaves like a primitive type or a C struct. It has a simple layout in memory with no v-table pointer, and is essentially inert, not responding in unusual ways to copying, assignment, etc.

POD types can be constructed using initializers:

MyPodType pod = {"Pod one", 1};
MyPodType pods[] = {{"Pod one", 1}, {"Pod two", 2}, {"Pod three", 3}};

More formally, a POD type in C++ is an arithmetic type, enumerated type, pointer or pointer-to-member with any const qualification, or an array, struct, class or union of those. It must have no user-defined constructor or destructor (not even empty ones), no copy assignment operator, no reference members, no private or protected non-static members, no base classes and no virtual functions.

There is a standard is_pod<> type trait, which you can use to tell if a type is a POD type:

#include <type_traits>
#include <iostream>
#include <string>

// A non-POD type (has a user-defined constructor)
class C

// A POD type
class P

int main()
    std::cout << std::is_pod<int>::value << "\n";         // 1
    std::cout << std::is_pod<std::string>::value << "\n"; // 0
    std::cout << std::is_pod<C>::value << "\n";           // 0
    std::cout << std::is_pod<P>::value << "\n";           // 1