73 lines
1.2 KiB
C++
73 lines
1.2 KiB
C++
/*
|
|
VIM: let b:lcppflags="-std=c++14 -O2 -pthread"
|
|
VIM: let b:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM: let b:argv=""
|
|
*/
|
|
#include <iostream>
|
|
#include <exception>
|
|
#include <vector>
|
|
//#include <initializer_list>
|
|
|
|
template <typename CONT>
|
|
void print( CONT&& cont )
|
|
{
|
|
std::cout << "template ";
|
|
for( auto n : cont ){
|
|
std::cout << n << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
|
|
#if 1
|
|
void print( const std::initializer_list<auto>& cont )
|
|
{
|
|
std::cout << "initializer_list<auto> ";
|
|
for( auto n : cont ){
|
|
std::cout << n << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
|
|
#if 1
|
|
void print( const std::initializer_list<int>& cont )
|
|
{
|
|
std::cout << "initializer_list<int> ";
|
|
for( auto n : cont ){
|
|
std::cout << n << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
int main ( void )
|
|
{try{
|
|
|
|
std::vector<int> v = {1,2,3};
|
|
|
|
print(v);
|
|
|
|
|
|
print({3,4,5});
|
|
|
|
print({3LL,4LL,5LL});
|
|
|
|
print({3LL,4,5});
|
|
|
|
|
|
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;
|
|
}}
|
|
|