N
Nephi Immortal
I read rvalue reference article. Here is the website:
http://blogs.msdn.com/b/vcblog/arch...-references-c-0x-features-in-vc10-part-2.aspx.
I wrote my code below. I can only see that rvalue reference is used
in the first parameter of the operator+ function.
int main()
{
string s1( "01" );
string s2( "23" );
string s3 = s1 + s2 + "AB";
return 0;
}
After s3 executed, first function is called:
basic_string<_Elem, _Traits, _Alloc> operator+(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
Then, it moves in the right direction and second function is called:
basic_string<_Elem, _Traits, _Alloc> operator+(
basic_string<_Elem, _Traits, _Alloc>&& _Left,
const _Elem *_Right)
Until move assignment operator is reached.
Can you please be kind to demonstrate your code? How can two
functions be called like below?
basic_string<_Elem, _Traits, _Alloc> operator+(
const _Elem *_Left,
basic_string<_Elem, _Traits, _Alloc>&& _Right)
and
basic_string<_Elem, _Traits, _Alloc> operator+(
basic_string<_Elem, _Traits, _Alloc>&& _Left,
basic_string<_Elem, _Traits, _Alloc>&& _Right)
http://blogs.msdn.com/b/vcblog/arch...-references-c-0x-features-in-vc10-part-2.aspx.
I wrote my code below. I can only see that rvalue reference is used
in the first parameter of the operator+ function.
int main()
{
string s1( "01" );
string s2( "23" );
string s3 = s1 + s2 + "AB";
return 0;
}
After s3 executed, first function is called:
basic_string<_Elem, _Traits, _Alloc> operator+(
const basic_string<_Elem, _Traits, _Alloc>& _Left,
const basic_string<_Elem, _Traits, _Alloc>& _Right)
Then, it moves in the right direction and second function is called:
basic_string<_Elem, _Traits, _Alloc> operator+(
basic_string<_Elem, _Traits, _Alloc>&& _Left,
const _Elem *_Right)
Until move assignment operator is reached.
Can you please be kind to demonstrate your code? How can two
functions be called like below?
basic_string<_Elem, _Traits, _Alloc> operator+(
const _Elem *_Left,
basic_string<_Elem, _Traits, _Alloc>&& _Right)
and
basic_string<_Elem, _Traits, _Alloc> operator+(
basic_string<_Elem, _Traits, _Alloc>&& _Left,
basic_string<_Elem, _Traits, _Alloc>&& _Right)