home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16827 < prev    next >
Encoding:
Text File  |  1992-11-24  |  2.2 KB  |  58 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!sol.deakin.OZ.AU!news.cs.uow.edu.au!cssc-syd.tansu.com.au!pete
  3. From: pete@cssc-syd.tansu.com.au (Peter Alexander Merel)
  4. Subject: Re: Templates parameterized on templates (!)
  5. Message-ID: <1992Nov24.030358.26152@cssc-syd.tansu.com.au>
  6. Organization: AOTC - CSSC
  7. References: <1992Nov19.215956.20239@cssc-syd.tansu.com.au> <1992Nov21.180344.101927@Cookie.secapl.com>
  8. Date: Tue, 24 Nov 1992 03:03:58 GMT
  9. Lines: 47
  10.  
  11. frank@Cookie.secapl.com (Frank Adams) writes:
  12. >pete@cssc-syd.tansu.com.au (Peter Alexander Merel) writes:
  13. >>template<template Container, class T>
  14. >>class troppo
  15. >>:
  16. >>    public Container<T>
  17. >>{
  18. >>    ...
  19. >>};
  20. >>
  21. >I'm not up on whether real live 3.0 compilers will do this
  22.  
  23. >They don't, and I think they should, too.  But the first line should
  24. >probably be either:
  25. >
  26. >template<template<class> Container, class T>
  27. >or
  28. >template<template Container<class>, class T>
  29.  
  30. You're right - there's not much checking the compiler can do at the template
  31. level, but at least it can see that we've got the right number of arguments.
  32.  
  33. >In the mean time, you can write:
  34. >template<class Container, class T>
  35. >
  36. >with the assertion that the template will only work if Container is a
  37. >container class whose element type is T.
  38.  
  39. I'm after something more powerful than this. The containers in the OSE class
  40. library all have different interfaces - there are maps, sets, lists, and all
  41. manner of whatnot, all (well, most, but for my purposes all) based on a
  42. class that will return an iterator and do a number of useful common services.
  43.  
  44. I want to make available this variety of templated containers from within a 
  45. value-added template of mine. If templates cannot be parameterised on 
  46. templates, then I am forced to write a dozen or so templates to do this, one 
  47. for each templated container type. 
  48.  
  49. If templates could be parameterised on other templates then I could accomplish
  50. this with just a single template, and of course this template would be
  51. extensible as OSE evolves ... which sounds like the finest kind of interface
  52. to me.
  53.  
  54. -- 
  55. Internet: pete@cssc-syd.tansu.com.au   UUCP: {uunet,mcvax}!munnari!cssc-syd!pete
  56. Snail: 1/18-20 Orion Road, Lane Cove NSW 2066 Australia    Phone: +61 2 911 3130
  57. I am a big pond in a small fish.
  58.