Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prototype of the iod option parser
#include "iod/parse_options.hh"
#include "symbols.hh"
using namespace s;
int main(int argc, char* argv[])
{
auto options = iod::parse_options(argc, argv,
_size | _s = int(20),
_elts | _e = std::vector<int>(),
_opt | _o = optional(int(3))
);
std::cout << options.size << " " << options.opt << " " << options.elts.size() << std::endl;
// Fill global variables
auto options = iod::parse_options(argc, argv,
_size | _s = &a_int_var,
_elts | _e = &a_vector,
_opt | _o = &another_var
);
// Positional arguments
auto options = iod::parse_options(argc, argv,
_size | _s = int(20),
_elts | _e = std::vector<int>(),
_opt | _o = optional(int(3)),
[ _size, _opt ]
);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.