Такое можно починить как-нибудь?
#include <iostream>
#include <cstdlib>
#include <typeinfo>
#include <memory>
template<typename IdClass, typename TaskClass, template <typename> class LoggerClass>
class BigVertex
{
private:
IdClass i;
TaskClass t;
public:
void bar(const TaskClass & t){ LoggerClass<TaskClass>::Log(t); };
};
template<typename BigGraphClass>
class HttpHandler
{
BigGraphClass b;
typename BigGraphClass::TaskClassT t;
typedef BigVertex<
typename BigGraphClass::IdClassT,
typename BigGraphClass::TaskClassT,
typename BigGraphClass::LoggerClassT
> MyBigVertex;
std::shared_ptr<MyBigVertex> lp_begin;
public:
void handle(){ lp_begin.reset(new MyBigVertex()); lp_begin->bar(t); }
};
template<typename BigGraphClass>
class HttpServer
{
private:
HttpHandler<BigGraphClass> h;
public:
void xxx(){ h.handle(); }
};
template<typename IdClass, typename TaskClass, template <typename> class LoggerClass>
class BigGraph
{
public:
typedef IdClass IdClassT;
typedef TaskClass TaskClassT;
typedef LoggerClass<TaskClass> LoggerClassT;
private:
BigVertex<IdClass, TaskClass, LoggerClass> v;
public:
void foo(const TaskClass & t){ v.bar(t); };
};
template<typename TaskClass>
class Logger
{
void Log(const TaskClass & t){ std::cout << t << std::endl; };
};
int main(int argc, char** argv)
{
HttpServer<BigGraph<int,int,Logger>> h;
h.xxx();
return 0;
}
таки починил) если кому интересно: #include <iostream> #include <cstdlib> #include <typeinfo> #include <memory> template<typename IdClass, typename TaskClass, typename LoggerClass> class BigVertex { private: IdClass i; TaskClass t; public: void bar(const TaskClass & t){ LoggerClass::Log(t); }; }; template<typename BigGraphClass> class HttpHandler { BigGraphClass b; typename BigGraphClass::TaskClassT t; typedef BigVertex< typename BigGraphClass::IdClassT, typename BigGraphClass::TaskClassT, typename BigGraphClass::LoggerClassT > MyBigVertex; std::shared_ptr<MyBigVertex> lp_begin; public: void handle(){ lp_begin.reset(new MyBigVertex()); lp_begin->bar(t); } }; template<typename BigGraphClass> class HttpServer { private: HttpHandler<BigGraphClass> h; public: void xxx(){ h.handle(); } }; template<typename IdClass, typename TaskClass, template <typename> class LoggerClass> class BigGraph { public: typedef IdClass IdClassT; typedef TaskClass TaskClassT; typedef LoggerClass<TaskClass> LoggerClassT; private: BigVertex<IdClass, TaskClass, LoggerClass<TaskClass>> v; public: void foo(const TaskClass & t){ v.bar(t); }; }; template<typename TaskClass> struct Logger { static void Log(const TaskClass & t){ std::cout << t << std::endl; }; }; int main(int argc, char** argv) { HttpServer<BigGraph<int,int,Logger>> h; h.xxx(); return 0; }
Обсуждают сегодня