-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
58 lines (46 loc) · 1.52 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <algorithm>
#include <boost/program_options.hpp>
#include <iostream>
#include <limits>
#include <random>
#include <vector>
#include <libA.h>
namespace po = boost::program_options;
template <typename T>
std::vector<T> gen_buffer( size_t size )
{
std::uniform_int_distribution<T> dist( std::numeric_limits<T>::min(),
std::numeric_limits<T>::max() );
std::default_random_engine gen( time( 0 ) );
std::vector<T> buff( size );
std::generate( buff.begin(), buff.end(), [&]() { return dist( gen ); } );
return buff;
}
int main( int argc, char *argv[] )
{
try
{
po::options_description desc( "Options" );
desc.add_options()( "help", "Show help message" )(
"size", po::value<size_t>(), "Default buffer size" );
po::variables_map vm;
po::store( po::parse_command_line( argc, argv, desc ), vm );
po::notify( vm );
if( vm.count( "help" ) || !vm.count( "size" ) )
{
std::cout << desc << "\n";
return 1;
}
auto buff = gen_buffer<int>( vm["size"].as<size_t>() );
std::cout << "is_sorted before: " << std::boolalpha
<< std::is_sorted( buff.begin(), buff.end() ) << std::endl;
LibA::do_sort( buff );
std::cout << "is_sorted after: " << std::boolalpha
<< std::is_sorted( buff.begin(), buff.end() ) << std::endl;
}
catch( const po::error &ex )
{
std::cerr << ex.what() << '\n';
}
return 0;
}