Perhaps this is a use case for a Boost.Bimap where both keys are multisets, and an entry in the bimap represents a single connection between a user and the client. So for the following setup
U1 -> C1 C2 C3
U2 -> C4 C1
U3 -> C5 C1
you would have entries (U1, C1)
, (U1, C2)
, (U1, C3)
, (U2, C4)
, (U2, C1)
, (U3, C5)
and (U3, C1)
.
You can traverse both keys in their order, i.e. U1, U1, U1, U2, U3
on the left and C1, C1, C1, C2, C3, C4, C5
on the right. (Note how both sides contain repeated entries!)