File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1414#define LLVM_FUZZER_FUZZED_DATA_PROVIDER_H_
1515
1616#include < algorithm>
17+ #include < array>
1718#include < climits>
1819#include < cstddef>
1920#include < cstdint>
@@ -71,6 +72,8 @@ class FuzzedDataProvider {
7172
7273 // Returns a value from the given array.
7374 template <typename T, size_t size> T PickValueInArray (const T (&array)[size]);
75+ template <typename T, size_t size>
76+ T PickValueInArray (const std::array<T, size> &array);
7477 template <typename T> T PickValueInArray (std::initializer_list<const T> list);
7578
7679 // Writes data to the given destination and returns number of bytes written.
@@ -301,6 +304,12 @@ T FuzzedDataProvider::PickValueInArray(const T (&array)[size]) {
301304 return array[ConsumeIntegralInRange<size_t >(0 , size - 1 )];
302305}
303306
307+ template <typename T, size_t size>
308+ T FuzzedDataProvider::PickValueInArray (const std::array<T, size> &array) {
309+ static_assert (size > 0 , " The array must be non empty." );
310+ return array[ConsumeIntegralInRange<size_t >(0 , size - 1 )];
311+ }
312+
304313template <typename T>
305314T FuzzedDataProvider::PickValueInArray (std::initializer_list<const T> list) {
306315 // TODO(Dor1s): switch to static_assert once C++14 is allowed.
You can’t perform that action at this time.
0 commit comments