#include <iostream>
template < typename T > void foo( T, typename T:: const_iterator * = nullptr )
{ std:: cout << "(1) this type defines a nested type 'const_iterator'\n " ; }
template < typename T > void foo( T, typename T:: first_type * = nullptr )
{ std:: cout << "(2) this type defines a nested type 'first_type'\n " ; }
template < typename T > void foo( T, typename T:: result_type * = nullptr )
{ std:: cout << "(3) this type defines a nested type 'result_type'\n " ; }
#include <vector>
#include <utility>
#include <functional>
int main( )
{
std:: vector < int > a ;
foo( a) ; // (1) this type defines a nested type 'const_iterator'
// substitution failure for (2) and (3)
std:: pair < int ,int > b ;
foo( b) ; // (2) this type defines a nested type 'first_type'
// substitution failure for (1) and (3)
std:: function < bool ( int ,int ) > c ;
foo( c) ; // (3) this type defines a nested type 'result_type'
// substitution failure for (1) and (2)
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPCB0eXBlbmFtZSBUID4gdm9pZCBmb28oIFQsIHR5cGVuYW1lIFQ6OmNvbnN0X2l0ZXJhdG9yKiA9IG51bGxwdHIgKQp7IHN0ZDo6Y291dCA8PCAiKDEpIHRoaXMgdHlwZSBkZWZpbmVzIGEgbmVzdGVkIHR5cGUgJ2NvbnN0X2l0ZXJhdG9yJ1xuIiA7IH0KCnRlbXBsYXRlIDwgdHlwZW5hbWUgVCA+IHZvaWQgZm9vKCBULCB0eXBlbmFtZSBUOjpmaXJzdF90eXBlKiA9IG51bGxwdHIgKQp7IHN0ZDo6Y291dCA8PCAiKDIpIHRoaXMgdHlwZSBkZWZpbmVzIGEgbmVzdGVkIHR5cGUgJ2ZpcnN0X3R5cGUnXG4iIDsgfQoKdGVtcGxhdGUgPCB0eXBlbmFtZSBUID4gdm9pZCBmb28oIFQsIHR5cGVuYW1lIFQ6OnJlc3VsdF90eXBlKiA9IG51bGxwdHIgKQp7IHN0ZDo6Y291dCA8PCAiKDMpIHRoaXMgdHlwZSBkZWZpbmVzIGEgbmVzdGVkIHR5cGUgJ3Jlc3VsdF90eXBlJ1xuIiA7IH0KCiN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