1#ifndef ADIAR_FUNCTIONAL_H
2#define ADIAR_FUNCTIONAL_H
9#include <adiar/exception.h>
10#include <adiar/type_traits.h>
11#include <adiar/types.h>
40 template <
typename TypeSignature>
50 template <
typename...
Args>
63 template <
typename Arg>
69 template <
typename ValueType,
typename OutputIt>
80 typename = enable_if<!is_void<
81 typename std::iterator_traits<std::remove_reference_t<OutputIt>>
::value_type>>>
93 typename = enable_if<is_void<
94 typename std::iterator_traits<std::remove_reference_t<OutputIt>>
::value_type>>>
98 using value_type =
typename std::remove_reference_t<OutputIt>::container_type::value_type;
112 template <
typename ForwardIt>
116 using value_type =
typename ForwardIt::value_type;
120 throw out_of_range(
"Iterator range unable to contain all generated values");
133 template <
typename ForwardIt>
138 typename std::iterator_traits<std::remove_reference_t<ForwardIt>>
::value_type;
143 throw out_of_range(
"Iterator range unable to contain all generated values");
155 template <
typename VarType>
169 template <
typename RetType>
175 template <
typename ForwardIt>
179 using value_type =
typename std::remove_reference_t<ForwardIt>::value_type;
191 template <
typename Stream>
195 using value_type =
typename Stream::value_type;
198 if (!
s.can_pull()) {
return {}; }
206 template <
typename RetType>
211 if (
_end) {
return {}; }
function< optional< RetType >()> generator
Generator function that produces a new value of RetType for each call.
Definition functional.h:170
function< double(VarType)> cost
Cost function that assigns a cost to each variable.
Definition functional.h:156
function< void(Arg)> consumer
Consumer function of value of type Arg.
Definition functional.h:64
generator< typename std::remove_reference_t< ForwardIt >::value_type > make_generator(ForwardIt &&begin, ForwardIt &&end)
Wrap a begin and end iterator pair into a generator function.
Definition functional.h:177
std::function< TypeSignature > function
General-purpose polymorphic function wrapper.
Definition functional.h:41
function< bool(Args...)> predicate
Predicate function given value(s) of type(s) Args.
Definition functional.h:51
consumer< ValueType > make_consumer(OutputIt &&iter)
Wrap an iterator into a consumer function.
Definition functional.h:71
Core types.
Definition adiar.h:40
std::out_of_range out_of_range
Attempt to access elements outside of the given range.
Definition exception.h:43
std::optional< T > optional
An optional value, i.e. a possibly existent value.
Definition types.h:81