Nesting Templates

closed account (3hM2Nwbp)
I suppose that it would be easiest to start with what the expected result should be.

1
2
3
4
5
6
7
8

//The end result should be:
SocketAcceptor<Session<DownstreamPacket, UpstreamPacket>> acceptor;

class SocketAcceptor{};
class Session : public boost::shared_from_this</*Stuck here too, need to get template right*/>{};
class DownstreamPacket{};
class UpstreamPacket{};


The reason for this is to reuse the Session, and packet classes for different protocols. I've been working at it for about 4 hours now, but I can't get it right for the life of me. Any tips would be greatly appreciated.

Thanks,
Luc

oh...wow now I feel dumb. Just hit me
1
2
3
4
5
6
7
8
9

template<class T> SocketAcceptor{};
template<class D, class U> Session{};
template<int> UpstreamPacket{};
template<int> DownstreamPacket{};

SocketAcceptor<Session<DownstreamPacket<3>,UpstreamPacket<3>>> sa;

/// Focus on something hard enough and you'll never get it.  Take a 10 minute break and it's simple.  Apparantly. :\ 
Last edited on
Topic archived. No new replies allowed.