#include <iostream>
struct constants_concept
{
virtual uint32_t some_value() = 0;
};
template <typename Constants>
struct constants_model
: constants_concept
{
virtual uint32_t some_value() { return Constants::some; }
};
struct mainnet_constants
{
static const uint32_t some = 1337;
};
struct testnet
{
static const uint32_t some = 666;
};
template <typename Constants=mainnet_constants>
void foo()
{
std::cout << Constants::some << std::endl;
}
struct bar
{
template <typename Constants=mainnet_constants>
void set_cons()
{
cons_ = new constants_model<Constants>;
}
constants_concept* cons_;
};
int main()
{
foo();
foo<testnet>();
bar b;
//b.set_cons<testnet>();
b.set_cons();
std::cout << b.cons_->some_value() << std::endl;
#ifdef FOFOF
service foo;
foo.set_crypto(bitcoin);
foo.set_crypto(litecoin);
bitcoin.address addr("1foobar");
#endif
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RydWN0IGNvbnN0YW50c19jb25jZXB0CnsKICAgIHZpcnR1YWwgdWludDMyX3Qgc29tZV92YWx1ZSgpID0gMDsKfTsKdGVtcGxhdGUgPHR5cGVuYW1lIENvbnN0YW50cz4Kc3RydWN0IGNvbnN0YW50c19tb2RlbAogIDogY29uc3RhbnRzX2NvbmNlcHQKewogICAgdmlydHVhbCB1aW50MzJfdCBzb21lX3ZhbHVlKCkgeyByZXR1cm4gQ29uc3RhbnRzOjpzb21lOyB9Cn07CgpzdHJ1Y3QgbWFpbm5ldF9jb25zdGFudHMKewogICAgc3RhdGljIGNvbnN0IHVpbnQzMl90IHNvbWUgPSAxMzM3Owp9OwoKc3RydWN0IHRlc3RuZXQKewogICAgc3RhdGljIGNvbnN0IHVpbnQzMl90IHNvbWUgPSA2NjY7Cn07Cgp0ZW1wbGF0ZSA8dHlwZW5hbWUgQ29uc3RhbnRzPW1haW5uZXRfY29uc3RhbnRzPgp2b2lkIGZvbygpCnsKICAgIHN0ZDo6Y291dCA8PCBDb25zdGFudHM6OnNvbWUgPDwgc3RkOjplbmRsOwp9CgpzdHJ1Y3QgYmFyCnsKICAgIHRlbXBsYXRlIDx0eXBlb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