Re: Address of member in class scope
jam schrieb:
multiple virtual inheitance postpones the calculation of data members`
address to runtime using dynamic typing and for this I guess that many
implementations assume all data member addresses to be evaluated at
runtime
1) According to 14.3.2/1 a pointer to member is a valid argument
for a non-type template.
2) According to 5.19/2+4 we have the concept of a "pointer to
member constant expression":
"A pointer to member constant expression shall be created using
the unary & operator applied to a qualifiedid operand (5.3.1),
optionally preceded by a pointer to member cast (5.2.9)."
which is one of the valid components of a constant expression
capable to initialize a non-local static object. Exactly this kind of
initialization belongs to the static initializations occuring
*before*
dynamic initialization takes place.
Both (1) and (2) are *static* accesses to a pointer of member
and exactly this kind has been performed by the OP. This has
nothing to do with possible dynamic typing. Similarily I can
aquire the static address of a pure, virtual member function,
although those are usually known as pure incarnations of
runtime entities:
struct V {
virtual ~V() = 0;
virtual void foo() = 0;
};
template < void (V::*)() >
struct Tester {};
int main() {
Tester<&V::foo>(); // No problem -> Static access
}
(Btw.: The above program compiles successfully for all
three compiler's tested in my previous posting, *even*
for VS2005-SP1)
Greetings from Bremen,
Daniel Kr?gler
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]