Next layer: Boost.Asio mixins?

Did anyone create and use Boost.Asio mixins and can share his experience?
I especially wonder if there is a benefit or if it's just an exercise in
templates.
The reason I started to think about Boost.Asio mixins is that I see the
very same code in various classes which all use Boost.Asio objects. I
would assume that this is not only true in my projects but also in others.
Here's an example. Let's say we create a client class to connect to
another host. We could come up with something like this:
class client
{
public:
void resolve(std::string host, std::string service);
void connect(boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
void send(std::string msg);
void receive();
private:
boost::asio::ip::tcp::resolver r;
boost::asio::ip::tcp::socket s;
};
If we create another class to encapsulate a POSIX file descriptor we don't
need resolve() and connect() but send() and receive():
class posix_fd
{
public:
void send(std::string msg);
void receive();
private:
boost::asio::posix::stream_descriptor fd;
};
While the two classes are based on different I/O objects the
implementation of send() and receive() could be the same. That lead me to
create mixins with which I can define client and posix_fd like this:
class client :
public resolver
participants (1)
-
Boris Schaeling