#include #include #include #include #include #include namespace po = boost::program_options; int main( int argc, char *argv[] ) { po::options_description desc( "Allowed options" ); desc.add_options() ( "multitoken,m", po::value< std::vector< std::string > >()->multitoken(), "values" ) ( "file", po::value< std::string >(), "the file to process" ) ; po::positional_options_description p; p.add( "file", 1 ); po::variables_map vm; po::store( po::command_line_parser( argc, argv ).options( desc ).positional( p ).run(), vm ); po::notify( vm ); std::string file; if ( vm.count( "file" ) ) file = vm[ "file" ].as< std::string >(); std::vector< std::string > multi; if ( vm.count( "multitoken" ) ) multi = vm[ "multitoken" ].as< std::vector< std::string > >(); std::cout << "File: " << file << "\nMultitoken: "; std::copy( multi.begin(), multi.end(), std::ostream_iterator< std::string >( std::cout, " " ) ); std::cout << std::endl; }