Boost logo

Boost :

From: jsiek_at_[hidden]
Date: 2000-09-16 01:13:34


Template templates are never really needed, since they
can be replaced by using partial specialization. Instead
of having two versions of the code, one with template templates
and one with the partial spec. version, I think its better
to just maintain the one version that is more portable,
the partial spec. version. Also, the partial spec can
be replaced with something even more portable, but that
starts to get really messy...

with template templates:

  template<class U, template <class T> Container>
  struct bar {
    typedef Container<U> foo;
    ...
  };

  bar<int, std::vector> b;

with partial spec:

  template <class ContainerTag, class U>
  struct container_generator { };

  template <class U, class ContainerTag>
  struct bar {
    typedef typename container_generator<ContainerTag, U>::type fooX;
    ...
  };

  struct vector_tag { };

  template <class T>
  struct container_generator<vector_tag, T> {
    typedef std::vector<T> type;
  };
    
  bar<int, vector_tag> b;

Daryle Walker writes:
> Should we have a #define for template templates support in boost/config.hpp?
> This could give some flexibility for people who may want to use template
> templates as the best solution, but give alternate solutions if needed. (I
> was think of template templates for getting the standard algorithms to work
> with the range stuff.)
>
> --
>
>
>
>
>
>


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