BigMan wrote:
Why does an emtpy class require an explicit default ctor in order to
initialize const objects of that type:
class EmptyClass{};
class EmptyClass2
{
EmtpyClass2( ) { }
};
int main()
{
EmptyClass const a; // Error: uninitialized const.
EmtpyClass2 const b; // OK.
Because of the following linguistic nuance:
assert(0 == int());
Explicitely constructing a primitive with empty parens is defined as the
same as declaring the same primitive at static or global scope. (Facts on
the ground, it has "all bits zero" in it.)
This is so STL containers can construct primitives with reliable values if
you parameterize the container types to them. Given typename _Ty, which
could be anything, an STL container needs _Ty() to construct it and give it
a healthy value. (And recall that the act of collecting the value of an
uninitialized variable is undefined.)
Your compiler is extending the effect to empty classes, despite they have no
collectable bits to initialize.
--
Phlip
http://www.c2.com/cgi/wiki?ZeekLand