Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-08-30 16:25:27


> Gary Powell writes:
> > The problem is you can't add new versions of container_gen<> to the
> > namespace "std", if you can shoe horn in the container into the ggcl
> format
> > it works, otherwise its prohibited.
> >
> > namespace std {
> > template<class Selector, // no problem,
> > class value_type, // no problem here,
> > class allocator> // opps! new option,
> > struct container_gen<> {};
> >
> > };
>
> Actually, there's a way to get around this by templating
> the selector:
>
> template <class Allocator>
> struct garys_containerS { };
>
> template <class Allocator, class T>
> struct container_gen< garys_containerS<Allocator>, T>
> {
> typedef garys_container<T, Allocator> type;
> };
>
This works for one additional class type. How about three?
template<class Compare, class Equal, class Allocator>
struct garys_contianerS {};

template<class Compare, class Equal, class Allocator, class T>
struct container_gen<garys_containerS<Compare,Equal,Allocator>, T>
{
  typedef garys_container<T, Compare<T>, Equal<T>, Allocator> type;
};

I think this is prohibited. Its fine for the namespace ggcl, but not std.

> > The more I look at this, the more I think you should just take the
> container
> > as the template class argument instead of this extra key_struct type.
>
> The problem with this is that the value_type that will go into the
> container is
> really an implementation detail that the user shouldn't have to know
> about.
>
Ok, then how about back to the template template parameter?

template< template<class ValueType> EdgeListS = VectorCover,
         ...,>
    adjacency_list {};

template<class T>
struct VectorCover {
   std::vector<T> type;
};

Of course this feels even worse for user types.

template<class T>
struct garyCover {
    gary_container<T, gary::less<T>, gary::equal<T>, gary::allocator> type;
};

because I have to specify every bit of information about the container in my
cover structs.

Other than this "feels broken" (The original design and most of my proposed
changes.) I don't have a better suggestion. Jens? Is any of this what you
were originally thinking?

  Yours Truly,
  -Gary-

gary.powell_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk