94 lines
1.3 KiB
C++
94 lines
1.3 KiB
C++
/*
|
|
VIM: let b:lcppflags="-std=c++14 -O2 -pthread -I."
|
|
VIM: let b:wcppflags="/O2 /EHsc /DWIN32"
|
|
VIM: let b:argv=""
|
|
*/
|
|
#include <iostream>
|
|
#include <exception>
|
|
#include <trnx_vector.h>
|
|
|
|
namespace trnx {
|
|
|
|
struct A{
|
|
int a1;
|
|
};
|
|
|
|
void test()
|
|
{
|
|
trnx::vector<A> v;
|
|
v.push_back(A{0});
|
|
v.push_back(A{1});
|
|
v.push_back(A{2});
|
|
|
|
for(const auto& x : v)
|
|
{
|
|
std::cout << x.a1 << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
|
|
#if 1
|
|
struct MoveOnly
|
|
{
|
|
int d_datum;
|
|
|
|
// Allow moves
|
|
MoveOnly(MoveOnly&&) = default;
|
|
MoveOnly& operator=(MoveOnly&&) = default;
|
|
|
|
// Prevent copies
|
|
MoveOnly(const MoveOnly&) = delete;
|
|
MoveOnly& operator=(const MoveOnly&) = delete;
|
|
};
|
|
|
|
void lab1()
|
|
{
|
|
trnx::vector<MoveOnly> v;
|
|
v.push_back(MoveOnly{0});
|
|
v.push_back(MoveOnly{1});
|
|
v.push_back(MoveOnly{2});
|
|
|
|
for(const auto& x : v)
|
|
{
|
|
std::cout << x.d_datum << ' ';
|
|
}
|
|
std::cout << std::endl;
|
|
}
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
{
|
|
test();
|
|
lab1();
|
|
}
|
|
|
|
|
|
|
|
} // close namespace trnx
|
|
|
|
int main ( void )
|
|
{try{
|
|
|
|
trnx::main();
|
|
|
|
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;
|
|
}}
|
|
|