#include <iostream>
#include <utility>
#include <typeinfo>
using namespace std;
auto func() {
int a = 0 ;
auto increase = [ &a ]( int i = 1 ){ a += i ; } ;
auto print = [ &a ](){ cout << a << '\n' ; } ;
/*
cout << typeid( decltype( print ) ).name() << '\n'
<< typeid( decltype( increase ) ).name() << '\n' ;
*/
pair< decltype(increase), decltype(print) > p = make_pair( increase, print ) ;
return p ;
}
int main() {
auto lambdas = func() ;
auto increase = lambdas.first ;
auto print = lambdas.second ;
print() ;
increase() ;
print() ;
increase( 123456 ) ;
print() ;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dXRpbGl0eT4KI2luY2x1ZGUgPHR5cGVpbmZvPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKYXV0byBmdW5jKCkgewoJaW50IGEgPSAwIDsKCQoJYXV0byBpbmNyZWFzZSA9IFsgJmEgXSggaW50IGkgPSAxICl7IGEgKz0gaSA7IH0gOwoJYXV0byBwcmludCA9IFsgJmEgXSgpeyBjb3V0IDw8IGEgPDwgJ1xuJyA7IH0gOwoJLyoKCWNvdXQgPDwgdHlwZWlkKCBkZWNsdHlwZSggcHJpbnQgKSApLm5hbWUoKSA8PCAnXG4nCgkJIDw8IHR5cGVpZCggZGVjbHR5cGUoIGluY3JlYXNlICkgKS5uYW1lKCkgPDwgJ1xuJyA7CgkqLwoJcGFpcjwgZGVjbHR5cGUoaW5jcmVhc2UpLCBkZWNsdHlwZShwcmludCkgPiBwID0gbWFrZV9wYWlyKCBpbmNyZWFzZSwgcHJpbnQgKSA7CglyZXR1cm4gcCA7Cn0KCmludCBtYWluKCkgewoJCglhdXRvIGxhbWJkYXMgPSBmdW5jKCkgOwoJCglhdXRvIGluY3JlYXNlID0gbGFtYmRhcy5maXJzdCA7CglhdXRvIHByaW50ID0gbGFtYmRhcy5zZWNvbmQgOwoJCglwcmludCgpIDsKCWluY3JlYXNlKCkgOwoJcHJpbnQoKSA7CglpbmNyZWFzZSggMTIzNDU2ICkgOwoJcHJpbnQoKSA7CgkKCXJldHVybiAwOwp9