mirror of
https://github.com/github/codeql.git
synced 2025-12-24 20:56:33 +01:00
This simplifies several instances of metaprogramming by leveraging [constraints and concepts from C++20][1]. This: * gets rid of `std::enable_if` by usage of `requires`, making it more readable and yield better compiler messages. * uses `requires` instead of `static_assert` to enforce `TrapLabel` typing * simplifies all compile-time tests for validity of a given expression * uses some standard library concepts where possible * generalizes and simplifies `SwiftLocationExtractor` Notice that in order to use the `std::derived_from` concept, `virtual` inheritance had to be added to the label tags, because diamond inheritance is a problem otherwise. That's because `std::derived_from<T, U>` requires that `T*` be convertible to `U*`, which is false if there are multiple non-virtual inheritance paths from `U` to `T`. As tags never get actually instantiated, there is no runtime performance penalty in using `virtual` inheritance. [1]: https://en.cppreference.com/w/cpp/language/constraints