boostorg / program_options

Boost.org program_options module
http://boost.org/libs/program_options
110 stars 107 forks source link

Allow use of std::optional for optional arguments #108

Closed jonesmz closed 8 months ago

jonesmz commented 3 years ago

This is in addition to supporting boost::optional.

sjoubert commented 8 months ago

Any update on merging this? This would be really nice to avoid having to convert boost::optional to std::optional after parsing.

vprus commented 8 months ago

Does this PR even work? It refers to std::optional without ever including <optional>.

Ideally, both include of the header and this new definition should be conditional on the compiler supporting C++17. Are you willing to make such changes?

sjoubert commented 8 months ago

I quickly tested this and it seems to work. But yes, I might have some time to put into this. What should I check?

vprus commented 8 months ago

Yeah, I think you need a new branch/PR. For tests, they will be appreciated, but it's up to you.

jonesmz commented 8 months ago

the PR was pulled straight out of my work codebase's copy of boost. Used in production for over 5 years.

Feel free to adjust the PR directly, or to use an alternative PR written by someone else.

vprus commented 8 months ago

Folks, thanks for your interest and contribution; this is now merged in https://github.com/boostorg/program_options/pull/132.