First of all, this is more of a sanity check question to get some approval by people better-versed in the depths of the language standard than me.
Let's say I have the following types (though I left out any non-constructor and non-assignment member functions):
template<typename E> struct half_expr
{
};
class half : public half_expr<half>
{
public:
half();
explicit half(float);
template<typename E> half(const half_expr<E>&);
half& operator=(float);
template<typename E> half& operator=(const half_expr<E>&);
private:
half(std::uint16_t, bool);
std::uint16_t data_;
};
Well, on any reasonable implementation a half
shouldn't be anything else in memory than a plain std::uint16_t
. But I'm interrested in the guarantees from the standard. Here is my rationale according to the C++98/03 defition of POD:
half
cannot be a POD type, since it is has non-public fields, base-classes and user-defined constructors.
and the C++11 losened/extended definitions:
It should be trivially copyable, since it has only implicitly generated copy/move constructors/assignments, but only as long as those
float
and template versions don't count in any way, which I'm not completely sure of.It should also be standard layout, since it only has a single private field of fundamental type and a single empty non-virtual base class (which should be POD in any standard, right?)
The only thing that hinders a POD-classification is that it is not trivially default constructible, which might IMHO be overcome by using C++11's
half() = default
syntax.
My quite simple question is just: Is my rationale entirely correct or are there any things I overlooked or misinterpreted in the definitions, especially in light of the user-defined constructors and assignments somehow hindering a classification as trivially copyable?
Note: Even if you feel the urge to delegate this to some possible duplicate about POD and standard-layout types (which I could prefectly understand), a simple comment answering my actual question would still be nice, since this is a mere sanity check, which might occur simple or superflous to you, but I just want to be on the safe side.