old_mile.cpp and adl.cpp

This commit is contained in:
2021-11-20 13:15:23 +00:00
parent 222e402599
commit f4d6e67706
2 changed files with 244 additions and 0 deletions

59
cpp/adl.cpp Normal file
View File

@@ -0,0 +1,59 @@
/*
VIM: let b:cf5build="clang -std=c++20 -O2 -pthread -lstdc++ -I. {SRC} -o {OUT}"
VIM: let b:cf5run="{OUT}"
VIM-: let b:cppflags=g:Iboost.g:Itbb
VIM-: let b:ldflags=g:Lboost.g:Ltbb
VIM-: let b:ldlibpath=g:Bboost.g:Btbb
*/
#include <iostream>
#include <exception>
#include <chrono>
namespace ttt {
struct s {
};
void print( const s& t ){
std::cout << "ttt::print" << std::endl;
}
}
namespace C
{
template <typename T>
void print( T t ){
std::cout << "C::print" << std::endl;
}
template <typename T>
void call_print( const T& t ){
print( t );
}
};
int main ( void )
{try{
auto begin = std::chrono::high_resolution_clock::now();
//......
C::call_print(ttt::s{});
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> seconds = end - begin;
std::cout << "Time: " << seconds.count() << std::endl;
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;
}}