Boost logo

Boost :

From: Phil Bouchard (philippe_at_[hidden])
Date: 2008-08-18 03:42:22

Here is a discussion I started with Gordon 2 weeks ago and I wanted to share
globally because of its interesting features which aren't related to smart

"I think a huge container inside an application will always suffer from
imperfections and this could be a decent alternative to the problem. A map
mixed with a list, a vector mixed with a set or all four together offers an
infinite set of properties.

Let's put it this way. All new "unordered" and multiset containers could
easily be implemented as:
1) superc1st<double, list, vector> s1;
2) superc2nd<string, double, map, vector> s2;
3) superc2nd<string, double, map, map> s3;

Where (explicit specializations for sake of example and please disregard
missing "typename"s):
template <>
    class superc1st<double, list, vector> : public _list<0, void, double>,
_vector<1, void, double> {...};

Here are examples of its usage:
s1[0] = 5.8;

template <>
    class superc2nd<string, double, map, vector> : public _map<0, string,
double>::base, _vector<1, string, double>::base {...};

This one can be accessed as such:
s2["Height"] = 6.3; // <-- O(log n)
s2[10] = 5.9; // <-- O(1)

template <>
    class superc2nd<string, double, map, map> : public _map<0, string,
double>::base, _map<1, string, double>::base {...};

To access 3) we could add indexed types we can cast the container
to:s3.get<0>()["Age"] = 31;

The underscored containers will be defined as:
template <int I, typename T, typename U>
    struct _map : std::map<T, U>
        typedef std::map<T, U> base;

        base & get<I>() { return * this; } // explicit function spec. won't
work here (should be Ith type pack cast)

template <int I, typename T, typename U>
    struct _vector : std::vector<U>
        typedef std::vector<U> base;


I think this is very easy to implement, cleaner and much more flexible (can
use vectors and no container can be forgotten). My brain kernel example
already needs something similar extensively..."


Boost list run by bdawes at, gregod at, cpdaniel at, john at