for_each_group_with_left_t.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 #include <string>
8 #include <vector>
9 
10 using intvec_t = std::vector<int>;
11 using shortvec_t = std::vector<short>;
12 using strvec_t = std::vector<std::string>;
13 using floatvec_t = std::vector<float>;
17 
18 int
20 {
21 
22  // initialization stuff
23  art::ProductID const viid{2};
24  art::ProductID const vfid{3};
25  intvec_t const vi{1, 2, 3};
26  floatvec_t const vf{1.0, 1.1, 2.0, 2.1, 3.0, 3.1};
27  shortvec_t const vs{10, 11, 20, 21, 30, 31};
28  floatvec_t const vtest{2.0, 2.1, 4.0, 4.1, 6.0, 6.1};
29 
30  int k{};
31 
32  assns_abd_t assns;
33  assns_ab_t a1;
34 
35  for (long unsigned int i = 0; i < 3; ++i) {
36  auto p1 = art::Ptr<int>(viid, &vi[i], i);
37  for (long unsigned int j = 0; j < 2; ++j) {
38  auto p2 = art::Ptr<float>(vfid, &vf[k], k);
39  assns.addSingle(p1, p2, vs[k]);
40  a1.addSingle(p1, p2);
41  ++k;
42  }
43  }
44 
45  // use of art::for_each_group_with_left
46 
47  floatvec_t fvec;
48  auto floats = [&fvec](auto const& l, auto rs) {
49  for (auto f = begin(rs); f != end(rs); ++f) {
50  // std::cout << l;
51  fvec.push_back((**f) + l);
52  }
53  };
54 
56  // floats should be same as vf
57  for (auto i = 0; i < 6; ++i) {
58  std::cout << fvec[i] << "\n";
59  if (fvec[i] != vtest[i]) {
61  << "Float #" << i << "expected to be '" << vtest[i] << "', got '"
62  << fvec[i] << "' instead!\n";
63  }
64  }
65  return 0;
66 }
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
assns_abd_t::const_iterator ci_t
std::vector< short > shortvec_t
static QStrList * l
Definition: config.cpp:1044
std::vector< int > intvec_t
void for_each_group_with_left(art::Assns< A, B, D > const &assns, F func)
std::vector< float > floatvec_t
std::vector< std::string > strvec_t
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void addSingle(Ptr< left_t > const &left, Ptr< right_t > const &right, data_t const &data)
Definition: Assns.h:546
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Definition: StdUtils.h:72
Definition: fwd.h:31
typename art::const_AssnsIter< L, R, D, Direction::Forward > const_iterator
Definition: Assns.h:237
#define a1