Define `ElementOf(std::array<T, N>)`. One example usage is that this lets callers declare a `constexpr std::array` of all of the values of an enum they own, which they can then use in defining multiple fuzz domains. The existing options require workarounds that are slightly less intuitive or idiomatic. PiperOrigin-RevId: 715783923
diff --git a/fuzztest/domain_core.h b/fuzztest/domain_core.h index c31e2f8..b857227 100644 --- a/fuzztest/domain_core.h +++ b/fuzztest/domain_core.h
@@ -20,6 +20,7 @@ #include <array> #include <cmath> +#include <cstddef> #include <deque> #include <initializer_list> #include <limits> @@ -301,6 +302,12 @@ return internal::ElementOfImpl<T>(std::move(values)); } +template <typename T, std::size_t N> +auto ElementOf(std::array<T, N> values) { + return internal::ElementOfImpl<T>( + std::vector<T>(values.begin(), values.end())); +} + template <typename T> auto Just(T val) { return internal::ElementOfImpl<T>({std::move(val)});