
Joao Abecasis <jpabecasis@zmail.pt> writes:
John Maddock wrote:
How does this differ from boost::compressed_pair ?
Well, compressed_pair applies to a pair and compressed_member applies memberwise. In a situation where you have more than two members compressed_member may compact better.
Consider this situation:
struct A {}; struct B {};
struct C : compressed_member<A> , compressed_member<A, 1> , compressed_member<B, 1> , compressed_member<B, 1> { };
Here, each A gets its address but the Bs can share those same addresses. I think applying the optimization memberwise may scale better for arbitrary tuples.
I think the question is whether it's ever desirable to break the current C++ invariant that no two objects of the same type will ever share an address **in generic code** -- that is, when you don't know anything about the assumptions that may be made by that type. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com