Reduce the number of distinct ValueOr template instantiations
Prior to this commit, every ValueOr<std::integral_constant<U,u>>
is a seperate type for every value u. This commit adds a deduction guide which will map all of the above types onto the single type ValueOr<U>
. The instance which will be created next will invoke the constructor ValueOr<U>::ValueOr(U)
with an argument of type std::integral_constant<U,u>
which will be implicitly cast to U u
(thanks to the existence of the std::integral_constant<U,u>::operator U
conversion operator which return u
), and thus ValueOr<U>::m_value
will be copy-constructed from u
-- as opposed to having ValueOr<std::integal_constant<U,u>>::m_value
copy-constructed from std::integral_constant<U,u>{}
, and then jumping through several hoops to convert m_value
to type U
prior to actually using it...
Hopefully this will reduce the amount of types created during the compilation of functors which use ValueOr
generated by the python code generator which typically generates a std::integral_constant
constructor argument... (which assumes that the generated code does not explicitly specify/force the type of ValueOr
, but allows it to be deduced from its constructor argument type!)
(note: the description above is significantly longer than the actual change... ;-) )