ZeroErr
in_range.h
Go to the documentation of this file.
1 #pragma once
2 
5 
7 
8 namespace zeroerr {
9 
10 template <typename T>
11 class InRange : public DomainConvertable<T> {
12 public:
13  using ValueType = T;
14  using CorpusType = T;
15 
17 
18  InRange(T min, T max) : min(min), max(max) {}
19 
20  CorpusType GetRandomCorpus(Rng& rng) const override {
21  ValueType offsize = max - min + 1;
22  ValueType v = rng.bounded(offsize);
23  v = min + v;
24  return v;
25  }
26 
27  void Mutate(Rng& rng, CorpusType& v, bool only_shrink) const override {
28  CorpusType offsize = max - min + 1;
29  v = rng.bounded(offsize);
30  v = min + v;
31  }
32 };
33 
34 } // namespace zeroerr
35 
Definition: domain.h:42
Definition: in_range.h:11
ValueType max
Definition: in_range.h:16
InRange(T min, T max)
Definition: in_range.h:18
ValueType min
Definition: in_range.h:16
T CorpusType
Definition: in_range.h:14
CorpusType GetRandomCorpus(Rng &rng) const override
Definition: in_range.h:20
T ValueType
Definition: in_range.h:13
void Mutate(Rng &rng, CorpusType &v, bool only_shrink) const override
Definition: in_range.h:27
Definition: rng.h:30
uint32_t bounded(uint32_t range) noexcept
Definition: rng.h:126
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_POP
Definition: config.h:265
#define ZEROERR_SUPPRESS_COMMON_WARNINGS_PUSH
Definition: config.h:218
Definition: benchmark.cpp:17