Revert "Swift: use C++20 constraints and concepts to simplify code"

This commit is contained in:
Paolo Tranquilli
2023-08-21 17:40:15 +02:00
committed by GitHub
parent 6d85d0d0f7
commit 1daedd9fb6
7 changed files with 226 additions and 121 deletions

View File

@@ -9,7 +9,6 @@
#include <binlog/binlog.hpp>
#include <cmath>
#include <charconv>
#include <concepts>
namespace codeql {
@@ -83,8 +82,9 @@ class TrapLabel : public UntypedTrapLabel {
static TrapLabel unsafeCreateFromUntyped(UntypedTrapLabel label) { return TrapLabel{label.id_}; }
template <typename SourceTag>
requires std::derived_from<SourceTag, Tag> TrapLabel(const TrapLabel<SourceTag>& other)
: UntypedTrapLabel(other) {}
TrapLabel(const TrapLabel<SourceTag>& other) : UntypedTrapLabel(other) {
static_assert(std::is_base_of_v<Tag, SourceTag>, "wrong label assignment!");
}
};
// wrapper class to allow directly assigning a vector of TrapLabel<A> to a vector of
@@ -96,8 +96,8 @@ struct TrapLabelVectorWrapper {
std::vector<TrapLabel<TagParam>> data;
template <typename DestinationTag>
requires std::derived_from<Tag, DestinationTag>
operator std::vector<TrapLabel<DestinationTag>>() && {
static_assert(std::is_base_of_v<DestinationTag, Tag>, "wrong label assignment!");
// reinterpret_cast is safe because TrapLabel instances differ only on the type, not the
// underlying data
return std::move(reinterpret_cast<std::vector<TrapLabel<DestinationTag>>&>(data));