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,757 of 33,346    |
|    =?UTF-8?B?RGFuaWVsIEtyw7xnbGVy?= to All    |
|    Re: Are reference types CopyAssignable    |
|    20 Dec 11 13:33:05    |
   
   8ddacab9   
   From: daniel.kruegler@googlemail.com   
      
   Am 20.12.2011 21:06, schrieb Andrzej Krzemieński:   
   > This question seems rather simple, but I am unable to find a clear   
   > answer in the Standard. In fact, I have two similar questions.   
   > Does type int& ('int' is just for an example - I ask about any   
   > reference) meet the requirements of CopyAssignable?   
      
   This solely depends referenced object type. You have to satisfy both   
      
   t = rv   
   t = v   
      
   to be well-formed. This can only be well-formed, if   
      
   a) T is no reference to const   
   b) T is no reference to function (you cannot assign to a function reference,   
   because that would mean that you would attempt to modify the referenced   
   function)   
   b) T is a reference to object and this object type satisfies CopyAssignable   
   requirements.   
      
   While this is a mechanic application of rules, there is a much simpler way to   
   describe the same thing: In regard to expression-based requirements, the   
   well-formedness of an assignment expression is always determined by the   
   referenced type. This becomes    
   clear, once you recognize that these requirements are determined by *values*   
   not by types [If you look at above list will see that every required property   
   is always a property of the referenced type, never a property of the reference   
   itself].   
      
   For initialization situations (like CopyConstructible) this is different,   
   because now reference initialization rules are relevant. But there do not   
   exist assignment rules for references: Any (assignment) expression involving   
   references is just an    
   expression of values of some non-reference types.   
      
   > And a similar question, if type R is a reference type, does this   
   > expression return true or false?   
   > std::is_copy_assignable
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca