proxygen
folly::gen::detail::IsEmpty< emptyResult > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::IsEmpty< emptyResult >:
folly::gen::Operator< IsEmpty< emptyResult > > folly::gen::FBounded< Self >

Public Member Functions

 IsEmpty ()=default
 
template<class Source , class Value >
bool compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::Operator< IsEmpty< emptyResult > >
ResultGen compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Additional Inherited Members

- Protected Member Functions inherited from folly::gen::Operator< IsEmpty< emptyResult > >
 Operator ()=default
 
 Operator (Operator &&) noexcept=default
 
 Operator (const Operator &)=default
 
Operatoroperator= (Operator &&) noexcept=default
 
Operatoroperator= (const Operator &)=default
 

Detailed Description

template<bool emptyResult>
class folly::gen::detail::IsEmpty< emptyResult >

IsEmpty - a helper class for isEmpty and notEmpty

Essentially returns 'result' if the source is empty. Note that this cannot be called on an infinite source, because then there is only one possible return value.

Used primarily through 'isEmpty' and 'notEmpty' static values

bool hasPrimes = g | filter(prime) | notEmpty; bool lacksEvens = g | filter(even) | isEmpty;

Also used in the implementation of 'any' and 'all'

Definition at line 2065 of file Base-inl.h.

Constructor & Destructor Documentation

template<bool emptyResult>
folly::gen::detail::IsEmpty< emptyResult >::IsEmpty ( )
default

Member Function Documentation

template<bool emptyResult>
template<class Source , class Value >
bool folly::gen::detail::IsEmpty< emptyResult >::compose ( const GenImpl< Value, Source > &  source) const
inline

Definition at line 2070 of file Base-inl.h.

References testing::Value().

2070  {
2071  static_assert(
2072  !Source::infinite,
2073  "Cannot call 'all', 'any', 'isEmpty', or 'notEmpty' on "
2074  "infinite source. 'all' and 'isEmpty' will either return "
2075  "false or hang. 'any' or 'notEmpty' will either return true "
2076  "or hang.");
2077  bool ans = emptyResult;
2078  source | [&](Value /* v */) -> bool {
2079  ans = !emptyResult;
2080  return false;
2081  };
2082  return ans;
2083  }
bool Value(const T &value, M matcher)

The documentation for this class was generated from the following file: