You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Idea: Adding from_string to enum metafunction (#1185)
* Added from_string to enum metafunction
* Changed string to string_view
* Changed string to string_view in test result now too
* Enable from_string for flag_enums too, and use contract violation handling
Changed failures from unconditional abort to a type_safety violation (which defaults to abort but allows a customizable handler) because it really is a precondition violation so a contract makes sense
* Fix typo in regression test case
* For flag_enums, let from_string take a "( list, of_multiple, flags )"
* Changed flag_enum to_string from (a,b) to (a|b)
And fixed bug to correct error case `break`
* Provide {to|from}_{string|code}
to_string/from_string round-trip, don't enum_name::-qualify, and represent a list with comma separators
to_code/from_code round-trip, do enum_name::-qualify, and represent a list with | separators
* Avoid repeated eval of to_string(prefix)
Add regress test case for to_code / from_code
Update regression test and generated files
---------
Signed-off-by: Herb Sutter <[email protected]>
Co-authored-by: Herb Sutter <[email protected]>
CPP2_UFCS(report_violation)(cpp2::type_safety, CPP2_UFCS(c_str)(("can't convert string '" + cpp2::to_string(s) + "' to flag_enum of type expression_flags")));
0 commit comments