proxygen
for_each_3.cpp File Reference
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
#include <folly/experimental/pushmi/examples/for_each.h>

Go to the source code of this file.

Functions

auto inline_bulk_target ()
 
int main ()
 

Function Documentation

auto inline_bulk_target ( )

Definition at line 25 of file for_each_3.cpp.

References folly::init(), folly::gen::move, folly::pushmi::set_error, and folly::pushmi::set_value.

Referenced by main().

25  {
26  return [](auto init,
27  auto selector,
28  auto input,
29  auto&& func,
30  auto sb,
31  auto se,
32  auto out) {
33  try {
34  auto acc = init(input);
35  for (decltype(sb) idx{sb}; idx != se; ++idx) {
36  func(acc, idx);
37  }
38  auto result = selector(std::move(acc));
39  mi::set_value(out, std::move(result));
40  } catch (...) {
41  mi::set_error(out, std::current_exception());
42  }
43  };
44 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
void init()
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
int main ( void  )

Definition at line 46 of file for_each_3.cpp.

References count, for_each(), inline_bulk_target(), and x.

46  {
47  std::vector<int> vec(10);
48 
50  inline_bulk_target(), vec.begin(), vec.end(), [](int& x) { x = 42; });
51 
52  assert(
53  std::count(vec.begin(), vec.end(), 42) == static_cast<int>(vec.size()));
54 
55  std::cout << "OK" << std::endl;
56 }
Definition: InvokeTest.cpp:58
const int x
auto inline_bulk_target()
Definition: for_each_3.cpp:25
Definition: Traits.h:588
int * count
vector< string > vec
Definition: StringTest.cpp:35
void for_each(T const &range, Function< void(typename T::value_type const &) const > const &func)