#include <iostream>
/**************************************************************************/
template<typename T>
void foo(T v) { std::cout << v.key << ": " << __PRETTY_FUNCTION__ << std::endl; }
template<typename T>
struct pair {
pair(T v)
:key("")
,val(v)
{}
pair(const char *k, T v)
:key(k)
,val(v)
{}
const char *key;
T val;
};
template<typename T>
auto make_pair(const char *key, T &val) {
return pair<T &>{key, val};
}
template<typename T>
auto make_pair(const char *key, const T &val) {
return pair<const T &>{key, val};
}
/**************************************************************************/
struct type {
int a;
int b;
type()
:a{}
,b{}
{}
void m0() const {
const auto p0 = make_pair("type.a", a);
foo(p0);
}
void m1() {
const auto p0 = make_pair("type.b", b);
foo(p0);
}
};
/**************************************************************************/
int main() {
type t;
t.m0();
t.m1();
int c=0;
const int d=0;
auto p0 = make_pair("b", 33);
foo(p0);
auto p1 = make_pair("c", c);
foo(p1);
auto p2 = make_pair("d", d);
foo(p2);
std::cout << "**********************************" << std::endl;
int f=0;
const int g=0;
foo(make_pair("i", 33));
foo(make_pair("f", f));
foo(make_pair("g", g));
}
/**************************************************************************/
I2luY2x1ZGUgPGlvc3RyZWFtPgoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kdm9pZCBmb28oVCB2KSB7IHN0ZDo6Y291dCA8PCB2LmtleSA8PCAiOiAiIDw8IF9fUFJFVFRZX0ZVTkNUSU9OX18gPDwgc3RkOjplbmRsOyB9Cgp0ZW1wbGF0ZTx0eXBlbmFtZSBUPgpzdHJ1Y3QgcGFpciB7CglwYWlyKFQgdikKCQk6a2V5KCIiKQoJCSx2YWwodikKCXt9CglwYWlyKGNvbnN0IGNoYXIgKmssIFQgdikKCQk6a2V5KGspCgkJLHZhbCh2KQoJe30KCgljb25zdCBjaGFyICprZXk7CglUIHZhbDsKfTsKCnRlbXBsYXRlPHR5cGVuYW1lIFQ+CmF1dG8gbWFrZV9wYWlyKGNvbnN0IGNoYXIgKmtleSwgVCAmdmFsKSB7CglyZXR1cm4gcGFpcjxUICY+e2tleSwgdmFsfTsKfQoKdGVtcGxhdGU8dHlwZW5hbWUgVD4KYXV0byBtYWtlX3BhaXIoY29uc3QgY2hhciAqa2V5LCBjb25zdCBUICZ2YWwpIHsKCXJldHVybiBwYWlyPGNvbnN0IFQgJj57a2V5LCB2YWx9Owp9CgovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiovCgpzdHJ1Y3QgdHlwZSB7CglpbnQgYTsKCWludCBiOwoKCXR5cGUoKQoJCTphe30KCQksYnt9Cgl7fQoKCXZvaWQgbTAoKSBjb25zdCB7CgkJY29uc3QgYXV0byBwMCA9IG1ha2VfcGFpcigidHlwZS5hIiwgYSk7CgkJZm9vKHAwKTsKCX0KCXZvaWQgbTEoKSB7CgkJY29uc3QgYXV0byBwMCA9IG1ha2VfcGFpcigidHlwZS5iIiwgYik7CgkJZm9vKHAwKTsKCX0KfTsKCi8qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCmludCBtYWluKCkgewoJdHlwZSB0OwoJdC5tMCgpOwoJdC5tMSgpOwoKCWludCBjPTA7Cgljb25zdCBpbnQgZD0wOwoJYXV0byBwMCA9IG1ha2VfcGFpcigiYiIsIDMzKTsKCWZvbyhwMCk7CglhdXRvIHAxID0gbWFrZV9wYWlyKCJjIiwgYyk7Cglmb28ocDEpOwoJYXV0byBwMiA9IG1ha2VfcGFpcigiZCIsIGQpOwoJZm9vKHAyKTsKCglzdGQ6OmNvdXQgPDwgIioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioiIDw8IHN0ZDo6ZW5kbDsKCWludCBmPTA7Cgljb25zdCBpbnQgZz0wOwoJZm9vKG1ha2VfcGFpcigiaSIsIDMzKSk7Cglmb28obWFrZV9wYWlyKCJmIiwgZikpOwoJZm9vKG1ha2VfcGFpcigiZyIsIGcpKTsKfQoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqLwo=