Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of string_view's - documentation #359

Open
eyalroz opened this issue Aug 9, 2022 · 5 comments
Open

Use of string_view's - documentation #359

eyalroz opened this issue Aug 9, 2022 · 5 comments

Comments

@eyalroz
Copy link
Contributor

eyalroz commented Aug 9, 2022

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.

@eyalroz eyalroz changed the title Use of string_view's Use of string_view's - documentation Aug 9, 2022
@jarro2783
Copy link
Owner

Can you give me an example of what you would like to do?

@eyalroz
Copy link
Contributor Author

eyalroz commented Aug 9, 2022

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
Copy link
Owner

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
Copy link
Contributor Author

eyalroz commented Aug 9, 2022

@jarro2783 : Ok, this is not an issue about making it work - just about mentioning whether it works on the Wiki page about options.

@jarro2783
Copy link
Owner

Ok sure. I'll add it to the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants