On Wed, Jun 3, 2015 at 9:24 AM, Andrzej Krzemienski
wrote:
Hi James,
I think I missed your previous announcement, so pardon me if I am asking
something you have already explained. What is the typical use case you are
trying to address, fromthe example on GitHub, I gather that:
heterogeneous::heterovector hv;
Is an alternative to:
struct vectors
{
std::vector<int> ints;
std::vector<double> doubles;
std::vectorstd::string strings;
std::vector<double> doubles1;
} hv;
Does it offer any advantages over the latter? Could you compare them,
so that I know what I ain by switching to your library?
Regards,
&rzej
Andrzej,
Thanks for the response. So yes, your example would provide pretty much
the same functionality. The heterocontainers would then be just a clean
interface to allow users to access the data without having to have an
ints0, ints1, int2, floats0, float1 and so forth in the struct. Maybe not
completely unique thing, but one could argue that a tuple
provides not much in additional benefit over what you could do with a
class tuple
{
int int_;
double double_;
float float_;
};
and defining a few methods to access that data.
My original idea was to have a container which does not require the user to
explicitly declare what data types the container will hold up front. Then,
for example, one could easily store insert the results of a database query
where the return type is not known at compile time. After some discussion,
it was determined that rather than having a dedicated container for this,
having generic methods which work with any sequence container of
boost::any/boost:variant or similar would be more flexible. That is
provided in the adaptor.hpp header with examples in example_adaptor.cpp.
There seemed to be some decent interest in the polymorphic collections
concept, and while what I have done isn't exactly the same, I think it is
close in concept. I figured it wasn't too much work so I went ahead and
did that as well.
--
James Armstrong