describe icon indicating copy to clipboard operation
describe copied to clipboard

Add program_options example with a generic custom validator for enums

Open sdebionne opened this issue 4 years ago • 7 comments

An example that shows how to support enums as options with Boost.ProgamOptions.

sdebionne avatar Jun 09 '21 07:06 sdebionne

Maybe update this to use enum_from_string and enum_to_string?

pdimov avatar Feb 19 '22 01:02 pdimov

Also, the op<< overload for described enums probably belongs to operators.hpp?

pdimov avatar Feb 19 '22 01:02 pdimov

Indeed, this PR needs an update... I have more of these kind of examples (e.g. integration with fmt::format, pybind11...), do you think it's worth merging them to your repos?

sdebionne avatar Mar 01 '22 09:03 sdebionne

I already added fmtlib examples.

pdimov avatar Mar 01 '22 15:03 pdimov

Also, the op<< overload for described enums probably belongs to operators.hpp?

AFAIU, using boost::describe::operators::operator<<; only works with described structs/classes not enum, no?

sdebionne avatar Mar 07 '22 10:03 sdebionne

Yes, but we can add an operator<< for enums there as well. Although that would make it impossible to use just one of the two as they are both called boost::describe::operators::operator<< so using will expose both.

pdimov avatar Mar 07 '22 15:03 pdimov

I think an overload of operator<< for enums would be welcome (just added in the fixup). What if we put them in different namespaces aka using boost::describe::enum_operators::operator<<; ?

sdebionne avatar Mar 07 '22 15:03 sdebionne