proxygen
folly::gen::detail::Take::Generator< Value, Source > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::Take::Generator< Value, Source >:
folly::gen::GenImpl< Value, Generator< Value, Source > > folly::gen::FBounded< Self >

Public Member Functions

 Generator (Source source, size_t count)
 
template<class Handler >
bool apply (Handler &&handler) const
 
- Public Member Functions inherited from folly::gen::GenImpl< Value, Generator< Value, Source > >
bool apply (Handler &&handler) const
 
void foreach (Body &&body) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Static Public Attributes

static constexpr bool infinite = false
 
- Static Public Attributes inherited from folly::gen::GenImpl< Value, Generator< Value, Source > >
static constexpr bool infinite
 

Private Attributes

Source source_
 
size_t count_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< Value, Generator< Value, Source > >
typedef Value ValueType
 
typedef std::decay< Value >::type StorageType
 
- Protected Member Functions inherited from folly::gen::GenImpl< Value, Generator< Value, Source > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Value, class Source>
class folly::gen::detail::Take::Generator< Value, Source >

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

Constructor & Destructor Documentation

template<class Value , class Source >
folly::gen::detail::Take::Generator< Value, Source >::Generator ( Source  source,
size_t  count 
)
inlineexplicit

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

706  : source_(std::move(source)), count_(count) {}
constexpr detail::Count count
Definition: Base-inl.h:2551
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class Value , class Source >
template<class Handler >
bool folly::gen::detail::Take::Generator< Value, Source >::apply ( Handler &&  handler) const
inline

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

References handler(), value, and testing::Value().

709  {
710  if (count_ == 0) {
711  return false;
712  }
713  size_t n = count_;
714  bool cancelled = false;
715  source_.apply([&](Value value) -> bool {
716  if (!handler(std::forward<Value>(value))) {
717  cancelled = true;
718  return false;
719  }
720  return --n;
721  });
722  return !cancelled;
723  }
void handler(int, siginfo_t *, void *)
bool Value(const T &value, M matcher)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)

Member Data Documentation

template<class Value , class Source >
size_t folly::gen::detail::Take::Generator< Value, Source >::count_
private

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

template<class Value , class Source >
constexpr bool folly::gen::detail::Take::Generator< Value, Source >::infinite = false
static

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

template<class Value , class Source >
Source folly::gen::detail::Take::Generator< Value, Source >::source_
private

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


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