Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
37 lines
961 B
C++
37 lines
961 B
C++
/*
|
|
* Copyright (C) 2021-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <variant>
|
|
#include <type_traits>
|
|
|
|
namespace utils {
|
|
|
|
// Given type T and an std::variant Variant, return std::true_type if T is a variant element
|
|
// This is also the recursion base case (empty variant), so return false.
|
|
template <typename T, typename Variant>
|
|
struct is_variant_element : std::false_type {
|
|
};
|
|
|
|
// Match - return true
|
|
template <typename T, typename... Elements>
|
|
struct is_variant_element<T, std::variant<T, Elements...>> : std::true_type {
|
|
};
|
|
|
|
// No match - recurse
|
|
template <typename T, typename U, typename... Elements>
|
|
struct is_variant_element<T, std::variant<U, Elements...>> : is_variant_element<T, std::variant<Elements...>> {
|
|
};
|
|
|
|
// Givent type T and std::variant, true if T is one of the variant elements.
|
|
template <typename T, typename Variant>
|
|
concept VariantElement = is_variant_element<T, Variant>::value;
|
|
|
|
}
|