C++11 is_pod with GCC 4.6

A POD struct must be a trivial class (C++11 §9[class]/10):

A POD struct is a non-union class that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD struct, non-POD union (or array of such types).

§9[class]/6 defines what a trivial class is:

A trivial class is a class that has a trivial default constructor and is trivially copyable.

§12.1[class.ctor]/5 defines what a trivial default constructor is. It begins:

A default constructor is trivial if it is not user-provided and...

The default constructor of Foo<T> is user-provided and is therefore nontrivial. Therefore, Foo<int> is not POD. It is, however, standard layout.


Default declaring default constructor, makes Foo a POD. i.e.

Foo() = default;
explicit Foo(T* obj) : m_data(obj)
{ }

http://ideone.com/vJltmA

Tags:

C++

Gcc

C++11