 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
ppliu Guest
|
Posted: Thu Oct 21, 2004 5:15 pm Post subject: why do we need this semantic ??? |
|
|
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 |
|
 |
|
|
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
|
|