Move all C++ tests to cpp.

This commit is contained in:
2014-05-31 22:55:50 +04:00
parent 1c1c6fe543
commit 7cdff553c8
52 changed files with 0 additions and 0 deletions

68
cpp/test_rvalue_ref.cpp Normal file
View File

@@ -0,0 +1,68 @@
#include <iostream>
#include <string>
class copy_tracker
{
int v;
public:
copy_tracker()
: v(0)
{
std::cout << "copy_tracker::copy_tracker()" << std::endl;
}
copy_tracker( const copy_tracker& c )
: v( c.v )
{
std::cout << "copy_tracker::copy_tracker( copy_tracker& c )" << std::endl;
}
void use_object() const
{
std::cout << v << std::endl;
}
};
copy_tracker create_rvalue()
{
return copy_tracker();
}
const copy_tracker create_const_rvalue()
{
return copy_tracker();
}
void f ( copy_tracker&& o )
{
o.use_object();
}
void f_const ( const copy_tracker&& o )
{
o.use_object();
}
void aaa( const std::string& s )
{
std::cout << s << std::endl;
}
int main( void )
{
f( create_rvalue() );
f_const( create_rvalue() );
f_const( create_const_rvalue() );
copy_tracker lvalue;
f( std::move(lvalue) );
f_const( std::move(lvalue) );
aaa( "aaaa");
return 0;
}