15 void WithMinSize(
unsigned _min_size) { this->min_size = _min_size; }
20 template <
typename T,
typename InnerDomain>
23 InnerDomain inner_domain;
27 using CorpusType = std::vector<typename InnerDomain::CorpusType>;
33 for (
const auto& elem : v) {
34 result.insert(inner_domain.GetValue(elem));
41 for (
const auto& elem : v) {
42 result.push_back(inner_domain.FromValue(elem));
50 for (
unsigned i = 0; i < E; i++) {
51 result.push_back(inner_domain.GetRandomCorpus(rng));
58 if (
size == -1 && action == 0) {
59 if (
static_cast<int>(v.size()) >
min_size)
60 v.erase(v.begin() + rng.
bounded(
static_cast<uint32_t
>(v.size())));
62 }
else if (
size == -1 && action == 1) {
63 if (
static_cast<int>(v.size()) <
max_size)
64 v.push_back(inner_domain.GetRandomCorpus(rng));
67 inner_domain.Mutate(rng, v[rng.
bounded(
static_cast<uint32_t
>(v.size()))], only_shrink);
72 template <
typename T,
typename InnerDomain>
75 InnerDomain inner_domain;
79 using CorpusType = std::vector<typename InnerDomain::CorpusType>;
93 for (
unsigned i = 0; i < E; i++) {
94 result.push_back(inner_domain.GetRandomCorpus(rng));
101 if (
size == -1 && action == 0) {
102 if (
static_cast<int>(v.size()) >
min_size) v.erase(v.begin() + rng.
bounded(
static_cast<uint32_t
>(v.size())));
104 }
else if (
size == -1 && action == 1) {
105 if (
static_cast<int>(v.size()) <
max_size)
106 v.push_back(inner_domain.GetRandomCorpus(rng));
108 inner_domain.Mutate(rng, v[rng.
bounded(
static_cast<uint32_t
>(v.size()))], only_shrink);
126 template <
typename T,
typename Inner>
127 typename std::enable_if<detail::is_associative_container<T>::value,
128 AssociativeContainerOf<T, Inner>>::type
133 template <
typename T,
typename Inner>
134 typename std::enable_if<!detail::is_associative_container<T>::value &&
135 detail::is_container<T>::value,
136 SequenceContainerOf<T, Inner>>::type
147 template <
template <
typename,
typename...>
class T,
typename... Inner,
148 typename C = T<
typename Inner::ValueType...>>
149 auto ContainerOf(Inner... inner) -> decltype(ContainerOf<C>(std::move(inner)...)) {
150 return ContainerOf<C>(std::move(inner)...);
Definition: container_of.h:22
std::vector< typename InnerDomain::CorpusType > CorpusType
Definition: container_of.h:27
AssociativeContainerOf(InnerDomain &&inner_domain)
Definition: container_of.h:29
void Mutate(Rng &rng, CorpusType &v, bool only_shrink) const override
Definition: container_of.h:56
T ValueType
Definition: container_of.h:26
CorpusType GetRandomCorpus(Rng &rng) const override
Definition: container_of.h:47
virtual CorpusType FromValue(const ValueType &v) const override
Definition: container_of.h:39
virtual ValueType GetValue(const CorpusType &v) const override
Definition: container_of.h:31
Domain class for generating random values of a specific type.
Definition: domain.h:22
uint32_t bounded(uint32_t range) noexcept
Definition: rng.h:126
Definition: container_of.h:74
SequenceContainerOf(InnerDomain &&inner_domain)
Definition: container_of.h:81
virtual ValueType GetValue(const CorpusType &v) const override
Definition: container_of.h:83
void Mutate(Rng &rng, CorpusType &v, bool only_shrink) const override
Definition: container_of.h:99
CorpusType GetRandomCorpus(Rng &rng) const override
Definition: container_of.h:90
virtual CorpusType FromValue(const ValueType &v) const override
Definition: container_of.h:86
T ValueType
Definition: container_of.h:78
std::vector< typename InnerDomain::CorpusType > CorpusType
Definition: container_of.h:79
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_POP
Definition: config.h:265
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
Definition: config.h:218
Definition: benchmark.cpp:17
std::enable_if< detail::is_associative_container< T >::value, AssociativeContainerOf< T, Inner > >::type ContainerOf(Inner &&inner)
Definition: container_of.h:129
Definition: container_of.h:11
int min_size
Definition: container_of.h:12
void WithSize(unsigned _size)
Definition: container_of.h:16
void WithMaxSize(unsigned _max_size)
Definition: container_of.h:14
int max_size
Definition: container_of.h:12
int size
Definition: container_of.h:12
void WithMinSize(unsigned _min_size)
Definition: container_of.h:15