#include <iostream>
#include <memory>

struct Base
{
	static std::shared_ptr<Base> Create(int args)
	{
		std::cout << "Base::Create(" << args << ")" << std::endl;
		return std::make_shared<Base>();
	}
};

template<typename T> struct Inherited: T
{
	static std::shared_ptr<Base> Create(int args)
	{
		return T::Create(args);
	}
};

struct Derived: Inherited<Base>
{
	static std::shared_ptr<Base> Create(int args)
	{
		if (args <= 0)
		{
			Inherited::Create(args);
		}
		else
		{
			std::cout << "Derived::Create(" << args << ")" << std::endl;
			return std::shared_ptr<Derived>();
		}
	}
};

int main()
{
	Derived::Create(0);
	Derived::Create(1);
	
	return 0;
}