Quote Originally Posted by exterminator
Is this the reason (in-lining) why you are not convinced if this can be space-efficient? Any other reasons?
I'm not convinced that templates are the horrible bloat-monsters that they get portrayed as. On the principle that you don't pay for what you don't use, then the mere existence of a template won't bloat code, and if you only use one function from a templated class, that's the only function that the compiler will expand from the template - which may be an improvement over writing separate versions of the class. On the assumption that if you're going to use the template, you would have written it longhand, anyway, I don't see how templates are worse than what you would have written. On the other hand, if you would have written something a bit less type-safe (so as to use one function where two or three would be better), then templates are encouraging you into better programming practices.

Anyway, this is all just gut feel and I have no data to back it up, but then I've seen no data to back up the code bloat theory, either (not that I've really looked).

As such, my preferred solution to the problem raised would be:
Code:
  template <typename T>
   struct myStruct
  {
     CString strVal;
 	T*vdptrVal;
  };
actually, it would be:
Code:
  template <typename T>
    struct myStruct
   {
  	std::string sensible_name_for_string_member;
  	T* sensible_name_for_pointer_member;
   };
where you can substitute something appropriate for the "sensible" names. I might keep the CString if the struct was directly associated with MFC classes, otherwise, I'd use std::string and convert to CString as late as possible. Plus, I detest Hungarian warts on variable names.