#include <iostream>
#include <memory>
using namespace std;
template<typename T>
struct Creator
{
static T* create() { return new T;}
};
struct Foo : public Creator<Foo>
{};
int main() {
Foo * foo = new Foo;
cout << "Is Foo? " << (dynamic_cast<Foo*>(foo) != nullptr) << endl;
cout << "Is Creator<Foo>? " << (dynamic_cast<Creator<Foo>*>(foo) != nullptr) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGU8dHlwZW5hbWUgVD4Kc3RydWN0IENyZWF0b3IKewogIHN0YXRpYyBUKiBjcmVhdGUoKSB7IHJldHVybiBuZXcgVDt9Cn07CgoKc3RydWN0IEZvbyA6IHB1YmxpYyBDcmVhdG9yPEZvbz4Ke307CgppbnQgbWFpbigpIHsKCQoJRm9vICogZm9vID0gbmV3IEZvbzsKCWNvdXQgPDwgIklzIEZvbz8gIiA8PCAoZHluYW1pY19jYXN0PEZvbyo+KGZvbykgIT0gbnVsbHB0cikgPDwgZW5kbDsKCWNvdXQgPDwgIklzIENyZWF0b3I8Rm9vPj8gIiA8PCAoZHluYW1pY19jYXN0PENyZWF0b3I8Rm9vPio+KGZvbykgIT0gbnVsbHB0cikgPDwgZW5kbDsKCQoJcmV0dXJuIDA7Cn0=