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 33,205 of 33,346   
   Jean-Marc Bourguet to Mathias Gaunard   
   Re: Will value semantics make C++ die?   
   13 Sep 13 07:33:37   
   
   From: jm@bourguet.org   
      
   Mathias Gaunard  writes:   
      
   > On 12/09/13 03:21, Jean-Marc Bourguet wrote:   
   >> Martin Ba <0xcdcdcdcd@gmx.at> writes:   
   >>   
   >>> I feel it's a very unfortunate design decision that the (comparison)   
   >>> operators try to save you the dereferencing.   
   >>   
   >> Are you arguing against   
   >>   
   >> template   
   >> bool operator<(optional const& x, optional const& y);   
   >>   
   >> or against   
   >>   
   >> template   
   >> bool operator<(optional const& x, T const& y);   
   >>   
   >> Considering that the constructor of optional from a T isn't explicit.   
   >> I could have some sympathy for arguing against the later one which   
   >> enable addition conversions.   
   >   
   > I don't see what it enables. You have to pass exactly a T, conversions   
   > cannot happen in this context, `y' has to be exactly the same type as   
   > the one in the optional.   
      
   Oops, got hit by the fact that with   
      
   template    
   class X {   
   public:   
       X();   
       X(T const&);   
       friend bool operator<(X const&, X const&) { return false; }   
   };   
      
   template    
   bool operator>(X const&, X const&) { return false; }   
      
   Operands of operator< are candidates for implicit conversion (it's a   
   function) while those of operator> (it's a template) aren't.  So we need   
   the overloads to be able to compare a optional with a T (something I   
   want).   
      
   Yours,   
      
   --   
   Jean-Marc   
      
      
         [ 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