// Target class.
class c {
static int si;
int i;
void fi( int arg ) { si = i = arg; }
};
int c::si;
// Library code.
template< typename type, type value, type & receiver >
class access_bypass {
static struct mover {
mover()
{ receiver = value; }
} m;
};
template< typename type, type value, type & receiver >
typename access_bypass< type, value, receiver >::mover
access_bypass< type, value, receiver >::m;
// Client code.
int *pcsi;
int c::*pci;
void (c::*pcfi)( int );
template class access_bypass< int *, & c::si, pcsi >;
template class access_bypass< int c::*, & c::i, pci >;
template class access_bypass< void (c::*)( int ), & c::fi, pcfi >;
#include <iostream>
int main() {
c a, b;
a.* pci = 3;
b.* pci = 5;
* pcsi = 8;
std::cout << a.* pci << ' ' << b.* pci << ' ' << * pcsi << '\n';
(a.* pcfi)( 7 );
std::cout << a.* pci << ' ' << b.* pci << ' ' << * pcsi << '\n';
}
Ly8gVGFyZ2V0IGNsYXNzLgoKY2xhc3MgYyB7CiAgICBzdGF0aWMgaW50IHNpOwogICAgaW50IGk7CiAgICB2b2lkIGZpKCBpbnQgYXJnICkgeyBzaSA9IGkgPSBhcmc7IH0KfTsKCmludCBjOjpzaTsKCi8vIExpYnJhcnkgY29kZS4KCnRlbXBsYXRlPCB0eXBlbmFtZSB0eXBlLCB0eXBlIHZhbHVlLCB0eXBlICYgcmVjZWl2ZXIgPgpjbGFzcyBhY2Nlc3NfYnlwYXNzIHsKICAgIHN0YXRpYyBzdHJ1Y3QgbW92ZXIgewogICAgICAgIG1vdmVyKCkKICAgICAgICAgICAgeyByZWNlaXZlciA9IHZhbHVlOyB9CiAgICB9IG07Cn07Cgp0ZW1wbGF0ZTwgdHlwZW5hbWUgdHlwZSwgdHlwZSB2YWx1ZSwgdHlwZSAmIHJlY2VpdmVyID4KdHlwZW5hbWUgYWNjZXNzX2J5cGFzczwgdHlwZSwgdmFsdWUsIHJlY2VpdmVyID46Om1vdmVyCiAgICBhY2Nlc3NfYnlwYXNzPCB0eXBlLCB2YWx1ZSwgcmVjZWl2ZXIgPjo6bTsKCi8vIENsaWVudCBjb2RlLgo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