I've been reading up on PODs in C++11, and several of the places I've read have said something about PODs supporting static initialization. For example:
The idea of a POD is to capture basically two distinct properties:
1. It supports static initialization, and
2. Compiling a POD in C++ gives you the same memory layout as a struct compiled in C.
(only the bolded part is relavent)
A type that is trivial can be statically initialized.
Apparently I'm not understanding what static initialization is. I thought making a global variable was an example of static initialization, but I can do the following and yet Foo isn't a POD:
#include <type_traits>
#include <iostream>
struct Foo {
  Foo() : x(0), y(0) {}
  int x;
  int y;
};
struct Bar {
  Bar() = default;
  int x;
  int y;
};
// Apparently the following two lines are not "static initialization" because
// Foo is non-POD yet we can still do this:
Foo f;
Bar b;
int main()
{
    if (std::is_pod<Foo>::value) std::cout << "Foo is a POD" << std::endl;
    else                         std::cout << "Foo is *not* a POD" << std::endl;
    if (std::is_pod<Bar>::value) std::cout << "Bar is a POD" << std::endl;
    else                         std::cout << "Bar is *not* a POD" << std::endl;
}
Foo is *not* a POD
Bar is a POD
So what exactly is static initialization, and how does it relate to trivial classes? Examples would be awesome.
 
     
     
     
     
     
    