From: dave@boostpro.com   
      
   on Wed Dec 07 2011, "Nevin \":-]\" Liber" wrote:   
      
   > In article ,   
   > Daniel Krügler 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?   
   >>   
   >> I don't think that boost_shared pointer (or std::shared_ptr) is a *bad*   
   >> example for providing operator<. The underlying pointer does provide it   
   >> and since a smart pointer mimics the built-in pointer to some degree,   
   >> this addition looks ok.   
   >   
   > I don't think (raw) pointers have a guaranteed total ordering. See   
   > C++11 5.9 for more details.   
      
   They don't, and AFAIK, this is the only raison d'être for std::less. In   
   my opinion, if you have found a suitable definition for std::less then   
   you have found your operator<. It's not meaningless if it is a valid   
   strict-weak ordering.   
      
   --   
   Dave Abrahams   
   BoostPro Computing   
   http://www.boostpro.com   
      
      
    [ 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)   
|