#include <iostream>
using namespace std;
class foo
{
public :
int bar;
} ;
template < class C, C>
class Check;
template < class T, class Enable = void >
class enable_if_has_bar
{ } ;
template < class T>
class enable_if_has_bar< T, Check < decltype( & T:: bar ) ,& T:: bar >>
{
public :
typedef decltype( static_cast < T* > ( 0 ) - > * static_cast < decltype( & T:: bar ) > ( 0 ) ) type;
} ;
template < class T>
typename enable_if_has_bar< T> :: type ReturnBar ( const T& value)
{
return value.bar ;
}
int main ( )
{
foo foobar;
foobar.bar = 42 ;
cout << ReturnBar( foobar) << endl;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCgpjbGFzcyBmb28KewpwdWJsaWM6CglpbnQgYmFyOwp9OwoKdGVtcGxhdGUgPGNsYXNzIEMsIEM+CmNsYXNzIENoZWNrOwoKdGVtcGxhdGUgPGNsYXNzIFQsIGNsYXNzIEVuYWJsZSA9IHZvaWQ+CmNsYXNzIGVuYWJsZV9pZl9oYXNfYmFyCnt9OwoKdGVtcGxhdGUgPGNsYXNzIFQ+CmNsYXNzIGVuYWJsZV9pZl9oYXNfYmFyPFQsIENoZWNrIDxkZWNsdHlwZSgmVDo6YmFyKSwmVDo6YmFyPj4KewpwdWJsaWM6Cgl0eXBlZGVmIGRlY2x0eXBlKHN0YXRpY19jYXN0PFQqPigwKS0+KnN0YXRpY19jYXN0PGRlY2x0eXBlKCZUOjpiYXIpPigwKSkgdHlwZTsKfTsKCnRlbXBsYXRlIDxjbGFzcyBUPgp0eXBlbmFtZSBlbmFibGVfaWZfaGFzX2JhcjxUPjo6dHlwZSBSZXR1cm5CYXIgKGNvbnN0IFQmIHZhbHVlKQp7CglyZXR1cm4gdmFsdWUuYmFyOwp9CgppbnQgbWFpbiAoKQp7Cglmb28gZm9vYmFyOwoJZm9vYmFyLmJhciA9IDQyOwoKCWNvdXQgPDwgUmV0dXJuQmFyKGZvb2JhcikgPDwgZW5kbDsKCXJldHVybiAwOwp9