on Fri Sep 07 2007, Dan Posluns
The Create() method would iterate over the subset, tally up the sizeof() for each class, and then perform a single allocation for data_buffer_for_properties and proceed to use placement new to instantiate each class in the subset. (The destructor would then clean up all of that ugliness.)
This sounds like a good job for Boost.Fusion
The which_properties_are_used member would be an efficient list manager that can be used to lookup the existence of properties, indexing the types in the set using the order<> operator.
Unfortunately, I haven't been able to get very far with set<>. I tried the following:
typedef fold< PropertiesSubset, int_<0>, plus< _1, sizeof_<_2> > >::type TotalSize;
cout << TotalSize::value;
... and it gives me nothing like what I'm looking for.
Huh... That won't give you anything useful anyway, because it doesn't account for the alignment requirement of the different types. I suggest using Fusion to build a tuple of the properties you're interested in. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com