VS成员指针的实现是否坑爹了

VS成员指针的实现是不是坑爹了?
不知道其他编译器会不会这样.
代码:


#include <iostream>
#include <string>
class A
{
public:
void afun()
{
std::cout << am;
}
std::string am;
};

class B
{
public:
void bfun()
{
std::cout << bm;
}
std::string bm;
};

class C:public A,public B
{
public :
void cfun()
{
std::cout << cm;
}
std::string cm;
};


int main()
{
C ci;
ci.am = "aaaaa";
ci.bm = "bbbbb";
ci.cm = "ccccc";
B * pb = &ci;

// case 1:     5.2.9.9 ISO/IEC 14882:2003(E) 
void (A::*pam)() = &A::afun;
void (C::*pcm)() = &C::cfun;
void (B::*pbm)() = static_cast<void (B::*)()>(pcm); // VS2012 says: warning C4407: 在指向成员表示形式的不同指针之间进行转换,编译器可能生成不正确的代码
(pb->*pbm)();

// case 2:   5.2.10.9 ISO/IEC 14882:2003(E)
pcm = reinterpret_cast<void (B::*)()>(pcm); // VS2012 says :error C2440: “reinterpret_cast”: 无法从“void (__thiscall C::* )(void)”转换为“void (__thiscall B::* )(void)”
// 你妹,static_cast 都能过的,reinterpret_cast就变错误了.
system("pause");
return 0;
};


注:

5.2.9.9 ISO/IEC 14882:2003(E) 
5.2.9 Static cast
9.An rvalue of type “pointer to member of D of type cv1 T” can be converted to an rvalue of type “pointer to
member of B of type cv2 T”, where B is a base class (clause 10) of D, if a valid standard conversion from
“pointer to member of B of type T” to “pointer to member of D of type T” exists (4.11), and cv2 is the same
cv-qualification as, or greater cv-qualification than, cv1.
63)The null member pointer value (4.11) is converted to the null member pointer value of the destination type. If class B contains the original member, or
is a base or derived class of the class containing the original member, the resulting pointer to member
points to the original member. Otherwise, the result of the cast is undefined.[Note: although class B need
not contain the original member, the dynamic type of the object on which the pointer to member is dereferenced must contain the original member; see 5.5. ]


 5.2.10.9 ISO/IEC 14882:2003(E)
5.2.10 Reinterpret cast 
9 An rvalue of type “pointer to member of X of type T1” can be explicitly converted to an rvalue of type
“pointer to member of Y of type T2” if T1 and T2 are both function types or both object types.66) The null
member pointer value (4.11) is converted to the null member pointer value of the destination type. The
result of this conversion is unspecified, except in the following cases:
— converting an rvalue of type “pointer to member function” to a different pointer to member function
type and back to its original type yields the original pointer to member value.
— converting an rvalue of type “pointer to data member of X of type T1” to the type “pointer to data member of Y of type T2” (where the alignment requirements of T2 are no stricter than those of T1) and back
to its original type yields the original pointer to member value.

------解决方案--------------------
我用g++编译通过VS成员指针的实现是否坑爹了
------解决方案--------------------
引用:
Quote: 引用:

我用g++编译通过VS成员指针的实现是否坑爹了

跑一下结果对吗?


结果是ccccc
------解决方案--------------------
static_cast和reinterpret_cast的功能本来就没有包含关系,只是有交集。

------解决方案--------------------
5.2.9.9 ISO/IEC 14882:2003(E) 
5.2.9 Static cast