last changes from bloomberg.
This commit is contained in:
42
cpp/cpp11/overload.cpp
Normal file
42
cpp/cpp11/overload.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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;
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user