home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13497 < prev    next >
Encoding:
Text File  |  1992-09-10  |  1.8 KB  |  47 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!stanford.edu!EE.Stanford.EDU!sierra!mcgrant
  3. From: mcgrant@rascals.stanford.edu (Michael C. Grant)
  4. Subject: Re: zero-length datatype
  5. In-Reply-To: jbn@lulea.trab.se's message of 9 Sep 92 19:58:05 GMT
  6. Message-ID: <MCGRANT.92Sep10142012@rascals.stanford.edu>
  7. Sender: usenet@EE.Stanford.EDU (Usenet)
  8. Organization: Information Systems Laboratory, Stanford University
  9. References: <TMB.92Sep8141523@arolla.idiap.ch> <4947@holden.lulea.trab.se>
  10. Distribution: comp
  11. Date: 10 Sep 92 14:20:12
  12. Lines: 33
  13.  
  14.  
  15.    tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
  16.    : In article <MCGRANT.92Sep7142456@rascals.stanford.edu> mcgrant@rascals.stanford.edu (Michael C. Grant) writes:
  17.    : 
  18.    :    I don't understand why those 4 bytes are causing you such a stink. Perhaps
  19.    :    you could enlighten us as to why a truly zero length data type is even
  20.    :    necessary?
  21.    : 
  22.    : Under the current rules,
  23.    : 
  24.    :       struct nothing {};
  25.    :       HashTable<int,nothing> table(1000000);
  26.    : 
  27.    : table takes up 8Mbytes (on most machines). If you could write
  28.    : 
  29.    :       HashTable<int,void> table(1000000);
  30.    : 
  31.    : table takes up 4Mbytes.
  32.  
  33. That wasn't my question... I would like an example where I would need to
  34. USE a void data type. In other words, Why is HashTable<int,void> a useful
  35. data type at all, and why can't we simply share code between
  36. HashTable<T1,T2> and another template HashTable<T1> which would be
  37. functionally equivalent to HashTable<T1,void>?
  38.  
  39. Perhaps, in fact, HashTable<T1> could be a base class for HashTable<T1,T2>,
  40. so as to maximize the possible code reuse...
  41.  
  42. I don't understand why a well-written C++ program should need to 
  43. operate on data that does not exist. If you give me a good example,
  44. I would appreciate it.
  45.  
  46. Michael C. Grant
  47.