Skip to content

Remove useless Optional wrapper from States functor

Gerhard Raven requested to merge fix-states-functor into master

There is no reason to return an 'unengaged' Optional<vector of states> from the States functor if the vector of States is empty. Instead, just return the underlying, empty vector...

In general, an optional exists to (*) extend the values represented by the underlying type by one in order to flag that there is no proper value of the underlying type. So using an 'optional' to represent a state which the underlying type is already capable of representing is a contradictio-in-terminis.

(*) there is one other reason, which is to explicitly be able to manage lifetimes, eg. to delay construction, or destruct prior to the end of the current scope, in a safe way, but that is not the case here.

Merge request reports