No. It is not. Actually there are places when you cannot have empty base class optimisation at all.
C++ standard mandates that two distinct objects should have different addresses.
consider following: std::tuple<char, empty, empty>
. No matter how you look (composition, inheritance), you have two empty
objects, which should have different addresses. This will increase size of tuple by at least 1.
Problem can arise from indirect inheritance:
struct derived: empty
{
char i;
};
std::tuple<derived, empty>
Here we have two empty
objects inside same class, and they have to have different addresses too, so you cannot optimise away second empty
member of tuple.
EDIT: found unexpected behaviour with empty bases and aligned_storage
stemming from agressive EBO: http://coliru.stacked-crooked.com/a/f45de2f889151ea3