Skip to content

Make LocalKey constexpr

Simon Praetorius requested to merge feature/constexpr-localkey into master

Summary

A LocalKey is essentially just a tuple with three named components, subEntity, codim, and index. There is no reason why this should not be constexpr. This would allow to use LocalKeys in other constexpr contexts. This MR implements this change.

Additionally, the observable properties are marked [[nodiscard]]. The consequence is that you cannot silently ignore the return value of these functions. This could, theoretically, break existing code. Thus, a system test will be run to make sure that in the many commonly used modules it has not effect. The attributes prevents from using these functions wrongly, e.g., forgetting to inspect the outcome of the functions.

Possible improvements

  • Make the operator< also constexpr. The comparison operator in std::array is constexpr with > c++20.
  • Allow to use the LocalKey in a structured binding. The easiest way would be to make it an actual aggregate type.
  • Make LocalKey usable in unordered containers, i.e., provide a hash function and a equal-comparison operator.

System pipelines

Edited by Simon Praetorius

Merge request reports

Loading