Closed ferkulat closed 6 years ago
Merging #45 into master will not change coverage. The diff coverage is
n/a
.
@@ Coverage Diff @@
## master #45 +/- ##
=======================================
Coverage 90.36% 90.36%
=======================================
Files 2 2
Lines 685 685
=======================================
Hits 619 619
Misses 66 66
Impacted Files | Coverage Δ | |
---|---|---|
include/clara.hpp | 87.67% <ø> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update a66d275...db3f8a1. Read the comment docs.
I've just implemented support for optionals. I forgot about this PR, so I did it slightly differently - although it's very similar.
The main difference is I do use __has_include(<optional>)
for detection, but along with __cplusplus >= 201703L
. It seems to work on all GCC (and Clang) versions we currently support - and doesn't break on Windows, AFAICS (but I don't think the auto-detection kicks in there, yet).
You can also manually override, and supply alternate optional types by #define
ing CLARA_CONFIG_OPTIONAL_TYPE
to some (template) type, e.g. boost::optional
(although I haven't tested that). It should work for any optional type that supports !
for validity and *
for extracting the value. The underlying type must still be default constructible.
I fixed parts of the optional support and added the extra tests.
I really like the idea to put command line options into optional values. This way the parser is not responsible for setting default values. And if one compiles with C++17 this PR would make it possible to deal with std::optional variables