Use C++20 concepts to require constraints on template parameters (#1977)

This commit is contained in:
Rangi
2026-05-22 17:54:34 -04:00
committed by GitHub
parent 728bed39d5
commit dce14fd4b8
12 changed files with 64 additions and 27 deletions
+4 -2
View File
@@ -12,6 +12,8 @@
#include <unordered_map>
#include <utility>
#include "helpers.hpp" // Enum
// A wrapper around iterables to reverse their iteration order; used in `for`-each loops.
template<typename IterableT>
struct ReversedIterable {
@@ -78,7 +80,7 @@ public:
};
// An iterable of `enum` values in the half-open range [start, stop).
template<typename EnumT>
template<Enum EnumT>
class EnumSeq {
EnumT _start;
EnumT _stop;
@@ -169,7 +171,7 @@ template<typename IterableT>
using ZipHolder = std::conditional_t<
std::is_lvalue_reference_v<IterableT>,
IterableT,
std::remove_cv_t<std::remove_reference_t<IterableT>>>;
std::remove_cvref_t<IterableT>>;
// Iterates over N containers at once, yielding tuples of N items at a time.
// Does the same number of iterations as the first container's iterator!