Topic: template<...> typedef ? (Reducing template arguments possible?


Author: thimm@physik.fu-berlin.de (Axel Thimm)
Date: 1997/04/01
Raw View
>> template<int N>
>> typedef MyMatrix<1,N> MyVector<N>;

>No, unfortunately, not.
>An alternative to inheritance is a helper class template:
>template<int N>
>struct Sub {
>   typedef MyMatrix<1, N> MyVector;
>};

This is a nice workaround. But I think that the standard should take up
something like a templated typedef. It seems usefull and fits naturally
in the current syntax.
I don't think this would have any impact on any other part of the
standard or burden implementations too much.
F. Henderson mentioned that this had once been considered, why was it
rejected? (was it?)

Regards,
 Axel Thimm.
--
Axel Thimm   thimm@physik.fu-berlin.de thimm@ifh.de
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: thimm@physik.fu-berlin.de (Axel Thimm)
Date: 1997/03/28
Raw View
Hello,

does the standard specify some procedure to "name" special templated
classes?
E.g.
template<int N>
typedef MyMatrix<1,N> MyVector<N>;
I wouldn't like to use inheritance, as I do not really need to. (And I
loose part of the base class also)

Regards,
 Axel Thimm.
--
Axel Thimm   thimm@physik.fu-berlin.de thimm@ifh.de
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]





Author: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Date: 1997/03/30
Raw View
thimm@physik.fu-berlin.de (Axel Thimm) writes:

>does the standard specify some procedure to "name" special templated
>classes?
>E.g.
>template<int N>
>typedef MyMatrix<1,N> MyVector<N>;

No, sadly it does not.

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: David Vandevoorde <daveed@vandevoorde.com>
Date: 1997/03/31
Raw View
Axel Thimm wrote:
[...]
> template<int N>
> typedef MyMatrix<1,N> MyVector<N>;
> I wouldn't like to use inheritance, as I do not really need to. (And I
> loose part of the base class also)

No, unfortunately, not.

An alternative to inheritance is a helper class template:

template<int N>
struct Sub {
   typedef MyMatrix<1, N> MyVector;
};

Not pretty, I admit.

That sort of workaround is used in at least one place of
the standard library (Allocator<T>::rebind).

 Daveed
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]