#include <type_traits>
#include <utility>
#include <iostream>
template <class F, class A> auto Call(
typename std::remove_reference<F>::type && f,
typename std::remove_reference<A>::type && a
) -> decltype(f(std::forward<A>(a))) {
return f(std::forward<A>(a));
}
struct Hoge { };
struct Func {
void operator () (Hoge const & hoge) const {
std::cout << "Hoge const &" << std::endl;
}
void operator () (Hoge && hoge) const {
std::cout << "Hoge &&" << std::endl;
}
};
int main(void) {
Call(Func(), Hoge());
return 0;
}
I2luY2x1ZGUgPHR5cGVfdHJhaXRzPgojaW5jbHVkZSA8dXRpbGl0eT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPGNsYXNzIEYsIGNsYXNzIEE+IGF1dG8gQ2FsbCgKCXR5cGVuYW1lIHN0ZDo6cmVtb3ZlX3JlZmVyZW5jZTxGPjo6dHlwZSAmJiBmLAoJdHlwZW5hbWUgc3RkOjpyZW1vdmVfcmVmZXJlbmNlPEE+Ojp0eXBlICYmIGEKKSAtPiBkZWNsdHlwZShmKHN0ZDo6Zm9yd2FyZDxBPihhKSkpIHsKCXJldHVybiBmKHN0ZDo6Zm9yd2FyZDxBPihhKSk7Cn0KCnN0cnVjdCBIb2dlIHsgfTsKCnN0cnVjdCBGdW5jIHsKCXZvaWQgb3BlcmF0b3IgKCkgKEhvZ2UgY29uc3QgJiBob2dlKSBjb25zdCB7CgkJc3RkOjpjb3V0IDw8ICJIb2dlIGNvbnN0ICYiIDw8IHN0ZDo6ZW5kbDsJCQoJfQoJdm9pZCBvcGVyYXRvciAoKSAoSG9nZSAmJiBob2dlKSBjb25zdCB7CgkJc3RkOjpjb3V0IDw8ICJIb2dlICYmIiA8PCBzdGQ6OmVuZGw7CQkKCX0KfTsKCmludCBtYWluKHZvaWQpIHsKCUNhbGwoRnVuYygpLCBIb2dlKCkpOwoJcmV0dXJuIDA7Cn0K