template specialization
<pre><code>template&lt;class T&gt; struct ISocket
{
    void connect(){}
    void raw_socket(){}
};

template &lt;class SocketType, class Arg1,class Arg2&gt;
struct ISocket&lt; SocketType(Arg1,Arg2) &gt; 
{
    typedef SocketType socket_type;
    typedef Arg1 arg_type;
    typedef Arg2 arg_type2;

    socket_type* raw_socket_;

    ISocket():raw_socket_(&amp;SocketType()){}


    socket_type&amp; raw_socket(){return *raw_socket_;}


    void connect()
    {
        raw_socket_-&gt;connect();
    } 
};
</code></pre>

<p>why I am obliged to define template struct ISocket; ? THe code below doesn't compile under VS2010, when you try to use ISocket and call connect for instance</p>

<pre><code>template&lt;class T&gt; struct ISocket;

template &lt;class SocketType, class Arg1,class Arg2&gt;
struct ISocket&lt; SocketType(Arg1,Arg2) &gt; 
{
    typedef SocketType socket_type;
    typedef Arg1 arg_type;
    typedef Arg2 arg_type2;

    socket_type* raw_socket_;

    ISocket():raw_socket_(&amp;SocketType()){}


    socket_type&amp; raw_socket(){return *raw_socket_;}


    void connect()
    {
        ref_raw_socket_-&gt;connect();
    } 
};
</code></pre>

<p>I call with this code :</p>

<pre><code>struct SocketTcp
{
    void setup(std::string ip,int port)
    {
        std::cout &lt;&lt; ip.c_str() &lt;&lt; " " &lt;&lt; port &lt;&lt; "\n";
    }

    void connect()
    {

    }
};


typedef ISocket&lt; SocketTcp(std::string, int) &gt; Socket;

int main()
{

    ISocket&lt;Socket&gt; s;

    s.connect();
    s.raw_socket(); 
}   
</code></pre>
