Use of string_view's - documentation
Opened this issue · 5 comments
eyalroz commented
Can one reliably use values which are string_view's? Where the default value is a non-owning reference, and so is the parsed value?
The Wiki should clarify this point IMHO.
jarro2783 commented
Can you give me an example of what you would like to do?
eyalroz commented
options.add_options()("filename", "description", cxxopts::value<std::string_view>())
and later
my_sv parse_result["filename"].as<std::string_view>();
and for that to work.
jarro2783 commented
At the moment that won't work because the strings passed around are a temporary constructed as the command line is looked at.
I'm not sure how much work it would be to make it possible, because there are also the default and implicit values to deal with in the same code.
eyalroz commented
@jarro2783 : Ok, this is not an issue about making it work - just about mentioning whether it works on the Wiki page about options.
jarro2783 commented
Ok sure. I'll add it to the wiki.