For example: I wanna write a easy-to-write & read #commandline / #cli option-parser for #cpp where you dont need to know how exactly #getopt works and what global variables & states it has.
One of the best other libraries out there for such stuff is #picocli ( https://picocli.info/ ). So naturally I wanna build something similar in #cpp .
But theres soooo many problems: bc c++ dosnt has real generics, only templates, there is ofc no typeerasure, meaning that I constantly need to pass around all template params. Wich means that theres no easy way having a type `Option<Cmd>` (options for a specific command), inside a list like `std::vector`! Even tho the storage space of a pointer is the same: 8 bytes, and thanks to virtual methods calling the right methods isnt a problem either!
Next up: fancy syntax! I wanna write options like this:
std::vector<Option<Cmd>> options = {
{ .names = {"-q", "--quiet"}, .handler = &Cmd::setQuiet },
}
But this is inefficent! Because the braces are so-called intitializer lists which effectivly only is a fancy way of calling the constructor! And because the inner braces are a Rvalue, they first need to be copied entirely to an Lvalue before they can be stored into a vector! Which means unnessecary memory operations!
Then I even cant declare it const: it would break std::find to actually find options!
Sure I could write
Option<Cmd> options[1] = { ... }
this would eliminate the copying. But then I have no iterateable AND need to write the count of options into the declaration! Aaaaarg qwq I just wanna write cute code qwq