proxygen
folly::gen::detail::CopiedSource< StorageType, Container > Class Template Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::CopiedSource< StorageType, Container >:
folly::gen::GenImpl< const StorageType &, CopiedSource< StorageType, Container > > folly::gen::FBounded< Self >

Public Types

typedef Container ContainerType
 
- Public Types inherited from folly::gen::GenImpl< const StorageType &, CopiedSource< StorageType, Container > >
typedef const StorageTypeValueType
 
typedef std::decay< const StorageType & >::type StorageType
 

Public Member Functions

template<class SourceContainer >
 CopiedSource (const SourceContainer &container)
 
 CopiedSource (Container &&container)
 
 CopiedSource (const CopiedSource< StorageType, Container > &source)
 
template<class Body >
void foreach (Body &&body) const
 
template<class Handler >
bool apply (Handler &&handler) const
 
- Public Member Functions inherited from folly::gen::GenImpl< const StorageType &, CopiedSource< StorageType, Container > >
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 ()
 

Public Attributes

std::shared_ptr< const Container > copy_
 

Static Public Attributes

static constexpr bool infinite = false
 
- Static Public Attributes inherited from folly::gen::GenImpl< const StorageType &, CopiedSource< StorageType, Container > >
static constexpr bool infinite
 

Additional Inherited Members

- Protected Member Functions inherited from folly::gen::GenImpl< const StorageType &, CopiedSource< StorageType, Container > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class StorageType, class Container>
class folly::gen::detail::CopiedSource< StorageType, Container >

CopiedSource - For producing values from eagerly from a sequence of values whose storage is owned by this class. Useful for preparing a generator for use after a source collection will no longer be available, or for when the values are specified literally with an initializer list.

This type is primarily used through the 'fromCopy' function, like:

auto sourceCopy = fromCopy(makeAVector()); auto sum = sourceCopy | sum; auto max = sourceCopy | max;

Though it is also used for the initializer_list specialization of from().

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

Member Typedef Documentation

template<class StorageType, class Container>
typedef Container folly::gen::detail::CopiedSource< StorageType, Container >::ContainerType

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

Constructor & Destructor Documentation

template<class StorageType, class Container>
template<class SourceContainer >
folly::gen::detail::CopiedSource< StorageType, Container >::CopiedSource ( const SourceContainer &  container)
inlineexplicit

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

194  : copy_(new Container(begin(container), end(container))) {}
std::shared_ptr< const Container > copy_
Definition: Base-inl.h:176
auto begin(TestAdlIterable &instance)
Definition: ForeachTest.cpp:56
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
template<class StorageType, class Container>
folly::gen::detail::CopiedSource< StorageType, Container >::CopiedSource ( Container &&  container)
inlineexplicit

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

197  : copy_(new Container(std::move(container))) {}
std::shared_ptr< const Container > copy_
Definition: Base-inl.h:176
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class StorageType, class Container>
folly::gen::detail::CopiedSource< StorageType, Container >::CopiedSource ( const CopiedSource< StorageType, Container > &  source)
inline

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

201  : copy_(source.copy_) {}
std::shared_ptr< const Container > copy_
Definition: Base-inl.h:176

Member Function Documentation

template<class StorageType, class Container>
template<class Handler >
bool folly::gen::detail::CopiedSource< StorageType, Container >::apply ( Handler &&  handler) const
inline

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

References handler(), and value.

211  {
212  // The collection may be reused by others, we can't allow it to be changed.
213  for (const auto& value : *copy_) {
214  if (!handler(value)) {
215  return false;
216  }
217  }
218  return true;
219  }
std::shared_ptr< const Container > copy_
Definition: Base-inl.h:176
void handler(int, siginfo_t *, void *)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
template<class StorageType, class Container>
template<class Body >
void folly::gen::detail::CopiedSource< StorageType, Container >::foreach ( Body &&  body) const
inline

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

References value.

204  {
205  for (const auto& value : *copy_) {
206  body(value);
207  }
208  }
std::shared_ptr< const Container > copy_
Definition: Base-inl.h:176
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)

Member Data Documentation

template<class StorageType, class Container>
std::shared_ptr<const Container> folly::gen::detail::CopiedSource< StorageType, Container >::copy_

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

template<class StorageType, class Container>
constexpr bool folly::gen::detail::CopiedSource< StorageType, Container >::infinite = false
static

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


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