17 #ifndef FOLLY_GEN_CORE_H_ 18 #error This file may only be included from folly/gen/Core.h 21 #include <type_traits> 40 template <
class Cand
idate,
class Expected>
42 static constexpr
bool value =
false;
45 template <
class Candidate,
class ExpectedReturn,
class... ArgTypes>
50 decltype(std::declval<F>()(std::declval<ArgTypes>()...)),
62 static constexpr
bool value = testArgs<Candidate>(
nullptr);
71 const Self&
self()
const {
72 return *
static_cast<const Self*
>(
this);
76 return *
static_cast<Self*
>(
this);
92 template <
class Source,
class Value,
class ResultGen =
void>
112 return Composed(left.
self(), right.
self());
145 template <
class Value,
class Self>
166 template <
class Handler>
172 template <
class Body>
173 void foreach(Body&& body)
const {
175 static_assert(!infinite,
"Cannot call foreach on infinite GenImpl");
176 body(std::forward<Value>(value));
191 static constexpr
bool infinite =
false;
205 "Generators may ony be combined if Values are the exact same type.");
206 return Chain(left.
self(), right.
self());
220 "Generators may ony be combined if Values are the exact same type.");
235 "Generators may ony be combined if Values are the exact same type.");
250 "Generators may ony be combined if Values are the exact same type.");
258 template <
class Value,
class Gen,
class Handler>
259 typename std::enable_if<
263 !Gen::infinite,
"Cannot pull all values from an infinite sequence.");
264 gen.
self().foreach(std::forward<Handler>(
handler));
271 template <
class Value,
class Gen,
class Handler>
275 return gen.
self().apply(std::forward<Handler>(
handler));
283 template <
class Value,
class Gen,
class Op>
285 -> decltype(
op.self().compose(gen.self())) {
286 return op.self().compose(gen.self());
289 template <
class Value,
class Gen,
class Op>
291 -> decltype(
op.self().compose(
std::move(gen.self()))) {
308 template <
class First,
class Second>
309 class Composed :
public Operator<Composed<First, Second>> {
314 Composed() =
default;
323 decltype(std::declval<First>().compose(std::declval<Source>())),
325 decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
327 return second_.compose(first_.
compose(source.
self()));
334 decltype(std::declval<First>().compose(std::declval<Source>())),
336 decltype(std::declval<Second>().compose(std::declval<FirstRet>()))>
350 template <
class Value,
class First,
class Second>
351 class Chain :
public GenImpl<Value, Chain<Value, First, Second>> {
359 template <
class Handler>
361 return first_.apply(std::forward<Handler>(
handler)) &&
362 second_.apply(std::forward<Handler>(
handler));
365 template <
class Body>
366 void foreach(Body&& body)
const {
367 first_.foreach(std::forward<Body>(body));
368 second_.foreach(std::forward<Body>(body));
371 static constexpr
bool infinite = First::infinite || Second::infinite;
#define FOLLY_GNU_DISABLE_WARNING(warningName)
#define FOLLY_POP_WARNING
#define FOLLY_PUSH_WARNING
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
void handler(int, siginfo_t *, void *)
static constexpr bool testArgs(int *)
bool Value(const T &value, M matcher)
Optional< StorageType > compose(const GenImpl< Value, Source > &source) const
auto operator|(GenImpl< Value, Gen > &&gen, const Operator< Op > &op) -> decltype(op.self().compose(std::move(gen.self())))
Chain(First first, Second second)
std::decay< Value >::type StorageType
SecondRet compose(GenImpl< Value, Source > &&source) const
static const char *const value
bool apply(Handler &&handler) const
Chain operator+(GenImpl< LeftValue, Left > &&left, GenImpl< RightValue, Right > &&right)
const Self & self() const
Composed(First first, Second second)
decltype(auto) constexpr apply(F &&func, Tuple &&tuple)
SecondRet compose(const GenImpl< Value, Source > &source) const
static constexpr bool testArgs(...)
constexpr detail::First first