|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-09 12:50:36
----- Original Message -----
From: "Lie-Quan Lee" <llee_at_[hidden]>
> With the current method of selecting component containers in BGL, if you
> want to use your own allocator into component conainers, you define your
> own selector. For example:
>
> struct my_vecS {};
> template <class ValueType>
> struct container_gen<my_vecS, ValueType> {
> typedef std::vector<ValueType, MyOwnAllocator> type;
> };
>
> This is simpler to users. Right?
Let's look at a more realistic case:
namespace my_company { namespace my_app {
...
// Oh, I need a graph!
struct my_vecS {};
// Damn, need to specialize container_gen before I can declare the
graph!
}}
namespace boost {
template <class ValueType>
struct container_gen<my_vecS, ValueType> {
typedef std::vector<ValueType, MyOwnAllocator> type;
};
}
namespace my_company { namespace my_app {
// declare the graph now
typedef boost::adjacency_list<my_VecS...
}}
--- Now, my version: ---
namespace my_company { namespace my_app {
...
// Oh, I need a graph!
struct my_vecS {
template <class ValueType>
struct apply {
typedef std::vector<ValueType, MyOwnAllocator> type;
};
};
typedef boost::adjacency_list<my_VecS...
}}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk