home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,889 of 33,346   
   Chris Stankevitz to All   
   Making some hard-coded types variadic te   
   02 Mar 13 04:24:37   
   
   dfd07892   
   From: chrisstankevitz@googlemail.com   
      
   Hello,   
      
   Regarding the code below...   
      
   Question: Can you recommend a way to remove the hard-coded types "int"   
   and "float" and make them "user-definable"?   
      
   By "user" I am referring to the author of "main".  By "user definable"   
   I mean the user can select the type and number of types.   
      
   //=====   
      
   template    
   struct Variant   
   {   
   };   
      
   template   
   struct Foo   
   {   
      template   
      struct Bar   
      {   
      };   
      
      typedef Variant, Bar > type;   
      
      Foo(const type& type0, const type& type1) {}   
   };   
      
   int main()   
   {   
      Foo foo(   
        Foo::Bar(),   
        Foo::Bar());   
      
      return 0;   
   }   
      
   //=====   
      
   Ideally...   
      
   1. Bar remains a sub-class of Foo.   
      
   2. The user specifies the types as "int, float" vs "Bar,   
   Bar"   
      
   3. The body of main looks like this:   
      Foo foo(   
        Foo::Bar(),   
        Foo::Bar());   
      
   Thank you,   
      
   Chris   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca