43 lines
702 B
C++
43 lines
702 B
C++
/*
|
|
VIM: let b:lcppflags="-std=c++11 -O2 -pthread"
|
|
VIM: let b:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM: let b:argv=""
|
|
*/
|
|
#include <iostream>
|
|
#include <exception>
|
|
#include <string>
|
|
|
|
void a( std::string&& s )
|
|
{
|
|
std::cout << " by value " << std::endl;
|
|
}
|
|
|
|
void a( const std::string& s )
|
|
{
|
|
std::cout << " const ref " << std::endl;
|
|
}
|
|
|
|
|
|
int main ( void )
|
|
{try{
|
|
std::string s = "bbbbbb";
|
|
|
|
a(s);
|
|
a(std::string("aaaa"));
|
|
|
|
return 0;
|
|
}
|
|
catch ( const std::exception& e )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "std::exception(\"" << e.what() << "\")." << std::endl;
|
|
return 2;
|
|
}
|
|
catch ( ... )
|
|
{
|
|
std::cerr << std::endl
|
|
<< "unknown exception." << std::endl;
|
|
return 1;
|
|
}}
|
|
|