halcheck 1.0
Loading...
Searching...
No Matches
label.hpp
1#ifndef HALCHECK_GEN_LABEL_HPP
2#define HALCHECK_GEN_LABEL_HPP
3
10#include <halcheck/lib/atom.hpp>
11#include <halcheck/lib/effect.hpp>
12#include <halcheck/lib/functional.hpp>
13#include <halcheck/lib/scope.hpp>
14#include <halcheck/lib/type_traits.hpp>
15
16#include <utility>
17
18namespace halcheck { namespace gen {
19
31
36 lib::finally_t<> fallback() const { return {}; }
37};
38
59static struct {
60 lib::finally_t<> operator()(lib::atom value) const { return lib::effect::invoke<label_effect>(value); }
61
62 template<typename F, typename... Args, HALCHECK_REQUIRE(lib::is_invocable<F, Args...>())>
63 lib::invoke_result_t<F, Args...> operator()(lib::atom value, F func, Args &&...args) const {
65 return lib::invoke(func, std::forward<Args>(args)...);
66 }
68
69}} // namespace halcheck::gen
70
71#endif
static lib::effect_result_t< T > invoke(T args)
Invokes an effect.
Definition effect.hpp:118
Calls a function upon destruction.
Definition scope.hpp:26
T forward(T... args)
static struct halcheck::gen::@9 label
Extends the unique identifiers passed to other random generation functions.
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
#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::finally_t fallback() const
By default, this effect does nothing.
Definition label.hpp:36
An effect for extending unique identifiers passed to other random generation functions.
Definition label.hpp:24
lib::atom value
The unique identifier to prefix. Calls to another function gen::func(my_label, ......
Definition label.hpp:30