1#ifndef HALCHECK_GEN_SHRINK_HPP
2#define HALCHECK_GEN_SHRINK_HPP
3#include <halcheck/gen/label.hpp>
4#include <halcheck/lib/atom.hpp>
5#include <halcheck/lib/effect.hpp>
6#include <halcheck/lib/functional.hpp>
7#include <halcheck/lib/iterator.hpp>
8#include <halcheck/lib/numeric.hpp>
9#include <halcheck/lib/optional.hpp>
10#include <halcheck/lib/pp.hpp>
11#include <halcheck/lib/scope.hpp>
12#include <halcheck/lib/type_traits.hpp>
22namespace halcheck {
namespace gen {
26 lib::optional<std::uintmax_t> fallback()
const {
return lib::nullopt; }
40 T &operator()(
lib::atom id, T &root, I begin, I end)
const {
53 return (*
this)(id, root, lib::begin(
range), lib::end(
range));
58 return (*
this)(id, root, lib::begin(
range), lib::end(
range));
73 T operator()(
lib::atom id, T root, F func)
const {
77 auto begin = lib::begin(children);
78 auto end = lib::end(children);
95 template<typename T, HALCHECK_REQUIRE(std::is_integral<T>())>
96 T
operator()(
lib::atom id, T dst, T src)
const {
117 template<typename T, HALCHECK_REQUIRE(std::is_floating_point<T>())>
118 T
operator()(
lib::atom id, T dst, T src)
const {
139 template<typename T, typename U, HALCHECK_REQUIRE(!std::is_same<T, U>())>
146 struct handler : lib::effect::handler<handler, gen::shrink_effect> {
147 lib::optional<std::uintmax_t> operator()(gen::shrink_effect)
final {
return lib::nullopt; }
150 handler::owning_scope operator()()
const {
return handler().handle(); }
152 template<
typename F,
typename... Args,
HALCHECK_REQUIRE(lib::is_invocable<F, Args...>())>
static lib::effect_result_t< T > invoke(T args)
Invokes an effect.
Definition effect.hpp:118
static struct halcheck::gen::@9 label
Extends the unique identifiers passed to other random generation functions.
static const range_t range
Generates a random value in an closed-open interval.
Definition range.hpp:93
std::uintmax_t size()
Gets the maximum size of value that should be generated.
Definition size.hpp:35
lib::variant< lib::symbol, lib::number > atom
An atom is either a symbol or a number.
Definition atom.hpp:194
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@20 invoke
An implementation of std::invoke.
decltype(lib::invoke(std::declval< F >(), std::declval< Args >()...)) invoke_result_t
An implementation of std::invoke_result_t.
Definition invoke.hpp:42
lib::iter_value_t< lib::iterator_t< R > > range_value_t
The type of element contained in a range.
Definition range.hpp:332
typename std::iterator_traits< I >::reference iter_reference_t
The return type of operator* for an iterator.
Definition base.hpp:24
lib::iter_reference_t< lib::iterator_t< R > > range_reference_t
The type returned by operator* for a range type's iterators.
Definition range.hpp:340
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::end_cpo::@28 end
Gets an iterator to past the end of a range.
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::begin_cpo::@27 begin
Gets an iterator to the first element of a range.
constexpr T midpoint(T min, T max) noexcept
An implementation of std::midpoint.
Definition numeric.hpp:24
static constexpr nullopt_t nullopt
An implementation of std::nullopt.
Definition optional.hpp:41
#define HALCHECK_INLINE_CONSTEXPR
A backwards-compatible substitute for inline constexpr.
Definition pp.hpp:70
typename std::common_type< Args... >::type common_type_t
An implementation of std::common_type_t.
Definition type_traits.hpp:133
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24
lib::variant< std::integral_constant< std::size_t, Ints >... > index(lib::atom id, lib::index_sequence< Ints... >={})
Generates a random std::integral_constant from the given set of indices.
Definition variant.hpp:39