C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

why do we need this semantic ???

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
ppliu
Guest





PostPosted: Thu Oct 21, 2004 5:15 pm    Post subject: why do we need this semantic ??? Reply with quote



C++ 98 8.5.3 says:

If the initializer expression is an rvalue, with T2 a class type, and
"cv1 T1" is referencecompatible
with "cv2 T2," the reference is bound in one of the following ways
(the choice is implementationdefined):
- The reference is bound to the object represented by the rvalue (see
3.10) or to a subobject
within
that object.
- A temporary of type "cv1 T2" [sic] is created, and a
constructor is called to copy the entire
rvalue object into the temporary. The reference is bound to the
temporary or to a subobject
within the temporary.93)

The constructor that would be used to make the copy shall be callable
whether or not the copy is
actually done

This disables the code below:

class X
{
X(const X&);
public:
X();
};
void f(X const&);
int main(){
f(X()); //error! X::X(const X&) un-callable
}

But IMO this semantic is absolutely unnecessary.
It disturbs "mojo",making it more complex.

Would you give me some example about the circumstance when the semantic
is necessary?

Thank you in advance.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.