The class phlex::experimental::identifier (from now on, just identifier) is in some contents where it is critical that the string never be empty, and in a few where it is allowable for the string to be empty.
For example, in phlex::detail::product_specification, the member suffix_ is an identifier that is allowed to be empty.
In phlex::experimental::algorithm_name (which is the unique identifier for a node in the graph), the member plugin_ is arguably allowed to be empty, while the member algorithm_ is not allowed to be empty.
In phlex::experimental::layer_path, the member layer_path_ is a std::vector<identifier> none of which should be empty.
The non-emptiness is not always currently enforced at runtime.
There has also been an intent to enforce other restrictions on identifiers, e.g. issue #343 to ensure that identifiers when turned into a std::string are valid C++ variable names.
I propose a change that would make the non-empty nature of identifier be a class invariant for the type, accompanied by the introduction of a new type that can have the state that represents either an identifier or an empty string; this type could have type aliases of suffix_t and plugin_name_t.
This would allow use of identifier as a type in code that would then never need to check if the "string" is empty, for example if emitting the stringified version as a label in a JSON/YAML/FHiCL document, etc., while allowing suffixes and plugin names to be empty when desired.
The class
phlex::experimental::identifier(from now on, justidentifier) is in some contents where it is critical that the string never be empty, and in a few where it is allowable for the string to be empty.For example, in
phlex::detail::product_specification, the membersuffix_is an identifier that is allowed to be empty.In
phlex::experimental::algorithm_name(which is the unique identifier for a node in the graph), the memberplugin_is arguably allowed to be empty, while the memberalgorithm_is not allowed to be empty.In
phlex::experimental::layer_path, the memberlayer_path_is astd::vector<identifier>none of which should be empty.The non-emptiness is not always currently enforced at runtime.
There has also been an intent to enforce other restrictions on
identifiers, e.g. issue #343 to ensure thatidentifiers when turned into astd::stringare valid C++ variable names.I propose a change that would make the non-empty nature of
identifierbe a class invariant for the type, accompanied by the introduction of a new type that can have the state that represents either anidentifieror an empty string; this type could have type aliases ofsuffix_tandplugin_name_t.This would allow use of
identifieras a type in code that would then never need to check if the "string" is empty, for example if emitting the stringified version as a label in a JSON/YAML/FHiCL document, etc., while allowing suffixes and plugin names to be empty when desired.