// 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, typename tag >
class access_bypass {
friend type get( tag )
{ return value; }
};
// Client code.
struct pcsi {};
struct pci {};
struct pcfi {};
int * get( pcsi );
int c::* get( pci );
void (c::* get( 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.* get( pci() ) = 3;
b.* get( pci() ) = 5;
* get( pcsi() ) = 8;
std::cout << a.* get( pci() ) << ' ' << b.* get( pci() ) << ' ' << * get( pcsi() ) << '\n';
(a.* get( pcfi() ) )( 7 );
std::cout << a.* get( pci() ) << ' ' << b.* get( pci() ) << ' ' << * get( pcsi() ) << '\n';
}
Ly8gVGFyZ2V0IGNsYXNzLgoKY2xhc3MgYyB7CiAgICBzdGF0aWMgaW50IHNpOwogICAgaW50IGk7CiAgICB2b2lkIGZpKCBpbnQgYXJnICkgeyBzaSA9IGkgPSBhcmc7IH0KfTsKCmludCBjOjpzaTsKCi8vIExpYnJhcnkgY29kZS4KCnRlbXBsYXRlPCB0eXBlbmFtZSB0eXBlLCB0eXBlIHZhbHVlLCB0eXBlbmFtZSB0YWcgPgpjbGFzcyBhY2Nlc3NfYnlwYXNzIHsKICAgIGZyaWVuZCB0eXBlIGdldCggdGFnICkKICAgICAgICB7IHJldHVybiB2YWx1ZTsgfQp9OwoKLy8gQ2xpZW50IGNvZGUuCgpzdHJ1Y3QgcGNzaSB7fTsKc3RydWN0IHBjaSB7fTsKc3RydWN0IHBjZmkge307CgppbnQgKiBnZXQoIHBjc2kgKTsKaW50IGM6OiogZ2V0KCBwY2kgKTsKdm9pZCAoYzo6KiBnZXQoIHBjZmkgKSApKCBpbnQgKTsKCnRlbXBsYXRlIGNsYXNzIGFjY2Vzc19ieXBhc3M8IGludCAqLCAmIGM6OnNpLCBwY3NpID47CnRlbXBsYXR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