Boost logo

Boost Users :

Subject: Re: [Boost-users] compressed fusion::vector?
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-09-01 10:54:35


On 08/31/10 16:01, Cory Nelson wrote:
> Hello,
>
> Is there a compressed fusion::vector that minimizes the size if the
> types passed in are empty, like compressed_pair? Thanks!
>
I know of none; however, using the
empty-base-class-optimization (EBO):

   http://www.cantrip.org/emptyopt.html

I'd guess that the method that inherits a "tagged" element for each
element in the tuple would avoid occupying any memory for empty
elements. A tagged element is one that is tagged with the element
index, as shown here:

https://svn.boost.org/trac/boost/browser/sandbox/variadic_templates/libs/mpl/sandbox/tuple_non_recur.package_range_c.cpp#L54

The tag is used to access that particular element. Further
explanations are in the reference found in the in-source comments
to tuple_non_recur.package_range_c.cpp.

I thought Christopher Schmidt's variadic fusion had a similar
implementation. I think it involves use of:

http://svn.boost.org/svn/boost/sandbox/SOC/2009/fusion/boost/fusion/container/vector/detail/variadic_templates/tagged_impl.hpp

However, after several minutes of greping and searching, now I can't
detect where it's used like that shown in:
tuple_non_recur.package_range_c.cpp.

I know several months ago there was a benchmark comparison done
that's reported in the thread containing this post:

http://article.gmane.org/gmane.comp.lib.boost.devel/194407

That comparison showed the tagged element implementation was slower;
however, as I said, it may save some space in case the compiler
implements EBO.

HTH.

-Larry


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net