#include <iostream>
#include <type_traits>
using namespace std;
class Figure {
public:
virtual void print() const = 0;
};
class Circle : public Figure {
public:
void print() const override {
cout << "Circle" << endl;
}
};
class Triangle : public Figure {
public:
void print() const override {
cout << "Triangle" << endl;
}
};
template <typename T>
void log(const T &figure) {
static_assert(std::is_base_of<Figure, T>::value,
"It has to be a Figure");
figure.print();
}
int main() {
Circle circle;
Triangle triangle;
log(circle);
log(triangle);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dHlwZV90cmFpdHM+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBGaWd1cmUgewoJcHVibGljOgoJCXZpcnR1YWwgdm9pZCBwcmludCgpIGNvbnN0ID0gMDsKfTsKCmNsYXNzIENpcmNsZSA6IHB1YmxpYyBGaWd1cmUgewoJcHVibGljOgoJCXZvaWQgcHJpbnQoKSBjb25zdCBvdmVycmlkZSB7CgkJCWNvdXQgPDwgIkNpcmNsZSIgPDwgZW5kbDsKCQl9Cn07CgpjbGFzcyBUcmlhbmdsZSA6IHB1YmxpYyBGaWd1cmUgewoJcHVibGljOgoJCXZvaWQgcHJpbnQoKSBjb25zdCBvdmVycmlkZSB7CgkJCWNvdXQgPDwgIlRyaWFuZ2xlIiA8PCBlbmRsOwoJCX0KfTsKCnRlbXBsYXRlIDx0eXBlbmFtZSBUPgp2b2lkIGxvZyhjb25zdCBUICZmaWd1cmUpIHsKCXN0YXRpY19hc3NlcnQoc3RkOjppc19iYXNlX29mPEZpZ3VyZSwgVD46OnZhbHVlLAoJCSJJdCBoYXMgdG8gYmUgYSBGaWd1cmUiKTsKICAgIAogICAgZmlndXJlLnByaW50KCk7Cn0KCmludCBtYWluKCkgewoJQ2lyY2xlIGNpcmNsZTsKCVRyaWFuZ2xlIHRyaWFuZ2xlOwoJCglsb2coY2lyY2xlKTsKCWxvZyh0cmlhbmdsZSk7CgkKCXJldHVybiAwOwp9