Re: inhibit compiler warning C4624 for a class hierarchy
<nitpick>
You seem to be using the term POD as a shortcut for "a fundamental type,
or a class with trivial constructor and destructor". Any POD struct has
trivial constructor and destructor, but not every one with trivial
constructor and destructor is POD.
For a structure to have a trivial constructor, it is necessary that all
its members also have a trivial constructor. They don't have to be PODs
(e.g. they could be classes derived from other classes, or have private
members). E.g.
struct A { int x; }; // POD
struct B : public A { int y; }; // not a POD
struct C { A a; B b; }; // not a POD
A, B and C all have trivial constructors and destructors. Only A is a
POD-struct. For all three it is legal to do something like
C* pc = (C*)malloc(sizeof(C));
// do something to pc
free(pc);
</nitpick>
Ok, this is all a necessary vs sufficient thing. But you're actually
accurate, the non-static data members do include trivially con/de-structed
types with private members, so I shouldn't use the term POD to apply to
them.
What's also needed is a noinherit keyword for class members that
affects name visibility, especially overload resolution, but not
access:
struct X
{
noinherit static int x;
static int y;
noinherit enum { xxx = 1; }
noinherit int f(int);
};
struct Y : public X
{
void f(double);
void test() {
x; // not allowed
X::x; // ok
I'm not sure how this is useful.
Utility is admittedly fairly low for data members. It would enable a
template function to distinguish between members declared on a type and
those inherited. Perhaps it would be better at the call site rather than
the declaration, I'm not sure.
xxx; // not allowed
__super::xxx; // ok
What would '__super' mean in the presense of multiple inheritance? In any
case, I still don't see how this construct is useful.
Well MSVC, which is the newsgroup we're in, already has a '__super' keyword.
f(1); // calls Y::f(double)
So it does now, without any new keyword.
I rather thought that Y::f(double) declared an overload of X::f(int) and
X::f(int) was a closer match for this call site...
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925