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 31,720 of 33,346   
   Nevin ":-]" Liber to Kevin McCarty   
   Re: Specializing std::less without an op   
   06 Dec 11 12:00:46   
   
   75b154f1   
   From: nevin@eviloverlord.com   
      
   In article   
   ,   
    Kevin McCarty  wrote:   
      
   > Or, as boost::shared_ptr does, is it regarded as preferable to instead   
   > go ahead and define an operator<() that returns lhs.get() < rhs.get()   
   > even though the result of the operator< is in general meaningless?   
      
   The compromise I use for these situations is to define operator< but not   
   >, <= or >=.   
      
   The problem is composibility.  If you go down the path of std::less   
   instead of operator<, and you want to use that type as a member of   
   another class that you wish to be able to use as a key in a set or a   
   map, you have to define a std::less for your new class (after all, if   
   the actual ordering for your original type is meaningless, any ordering   
   based on it is also meaningless).  It gets very clunky very quickly.   
      
      
   --   
         [ 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