1#ifndef HALCHECK_LIB_UTILITY_HPP
2#define HALCHECK_LIB_UTILITY_HPP
11#include <halcheck/lib/functional.hpp>
12#include <halcheck/lib/type_traits.hpp>
13#include <halcheck/lib/variant.hpp>
19namespace halcheck {
namespace lib {
40template<
typename T,
typename U = T>
42 T prev = std::move(value);
52template<
typename T, T... Ints>
64template<
typename,
typename T, T N, T... Ints>
67template<
typename T, T N, T... Ints>
70template<
typename T, T N, T... Ints>
81template<
typename T, T N>
89template<std::
size_t N>
95 explicit result_holder(T value) : _value(std::move(value)) {}
101 [](T &value) -> T & {
return value; },
106 const T &get()
const & {
return const_cast<result_holder *
>(
this)->get(); }
108 explicit operator bool()
const {
return lib::holds_alternative<std::exception_ptr>(_value); }
111 lib::variant<T, std::exception_ptr> _value;
115class result_holder<T &> {
117 explicit result_holder(T &value) : _value(&value) {}
123 [](T *value) -> T & {
return *value; },
128 const T &get() const & {
return const_cast<result_holder *
>(
this)->get(); }
130 explicit operator bool()
const {
return lib::holds_alternative<std::exception_ptr>(_value); }
133 lib::variant<T *, std::exception_ptr> _value;
137class result_holder<void> {
151lib::result_holder<
lib::invoke_result_t<F, Args...>> make_result_holder(F func, Args &&...args) {
160lib::result_holder<void> make_result_holder(F func, Args &&...args) {
163 return lib::result_holder<void>();
T current_exception(T... args)
HALCHECK_INLINE_CONSTEXPR struct halcheck::lib::@20 invoke
An implementation of std::invoke.
lib::overload< Args... > make_overload(Args... args)
Constructs an overloaded functor from a set of pre-existing functors.
Definition overload.hpp:48
decltype(lib::invoke(std::declval< F >(), std::declval< Args >()...)) invoke_result_t
An implementation of std::invoke_result_t.
Definition invoke.hpp:42
typename std::enable_if< Cond, T >::type enable_if_t
An implementation of std::enable_if_t.
Definition type_traits.hpp:93
#define HALCHECK_REQUIRE(...)
Expands to a template argument that is only valid if the given argument evaluates to true.
Definition type_traits.hpp:24
T exchange(T &value, U &&next)
An implementation of std::exchange.
Definition utility.hpp:41
static constexpr in_place_t in_place
An implementation of std::in_place.
Definition utility.hpp:33
T rethrow_exception(T... args)
An implementation of std::in_place_t.
Definition utility.hpp:26
An implementation of std::integer_sequence.
Definition utility.hpp:53
An implementation of std::make_integer_sequence.
Definition utility.hpp:82