Functions
test_tuple.cxx File Reference
#include "WireCellUtil/TupleHelpers.h"
#include "WireCellUtil/Testing.h"
#include <iostream>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 8 of file test_tuple.cxx.

9 {
10 
11  typedef std::tuple<int,float,double,char,std::string> IFDCS;
12  typedef tuple_helper<IFDCS> IFDCS_helper;
13  typedef shared_queued<IFDCS> IFDCS_shqed;
14  typedef IFDCS_shqed::shared_queued_tuple_type IFDCS_queues;
15 
16  IFDCS_helper ifdcs_helper;
17  IFDCS_shqed ifdcs_shqed;
18 
19  std::vector<std::string> typenames = ifdcs_helper.type_names();
20  for (auto tn : typenames) {
21  std::cerr << tn << std::endl;
22  }
23 
24  IFDCS ifdcs{1,2.2,3.0e-9,'a',"foo"};
25  //std::vector<boost::any> anyvec = as_any(ifdcs);
26  std::vector<boost::any> anyvec = ifdcs_helper.as_any(ifdcs);
27  std::cerr << boost::any_cast<int>(anyvec[0]) << std::endl;
28  std::cerr << boost::any_cast<std::string>(anyvec[4]) << std::endl;
29 
30  auto ifdcs2 = ifdcs_helper.from_any(anyvec);
31 
32 
33  //typedef typename tuple_helper<IFDCS>::Wrapped<std::deque>::type ifdcs_queues;
34  IFDCS_queues qs;
35  std::get<0>(qs).push_back(std::make_shared<int>(1));
36  std::get<1>(qs).push_back(std::make_shared<float>(2.2f));
37  std::get<2>(qs).push_back(std::make_shared<double>(3.0e-9));
38  std::get<3>(qs).push_back(std::make_shared<char>('a'));
39  std::get<4>(qs).push_back(std::make_shared<std::string>("foo"));
40 
41  auto any_q = ifdcs_shqed.as_any_queue(qs);
42  Assert (any_q.size() == 5);
43  for (auto q : any_q) {
44  Assert(q.size() == 1);
45  }
46 
47  auto qs2 = ifdcs_shqed.from_any_queue(any_q);
48 
49  using boost::any_cast;
50 
51  std::cerr << "First element from each queue:\n";
52  std::cerr << *std::get<0>(qs2)[0] << std::endl;
53  std::cerr << *std::get<1>(qs2)[0] << std::endl;
54  std::cerr << *std::get<2>(qs2)[0] << std::endl;
55  std::cerr << *std::get<3>(qs2)[0] << std::endl;
56  std::cerr << *std::get<4>(qs2)[0] << std::endl;
57 
58  // for (auto a: as_any(std::get<0>(qs))) {
59  // std::cerr << boost::any_cast<int>(a) << std::endl;
60  // }
61  typedef typename IFDCS_helper::Wrapped<std::vector>::type ifdcs_vectors;
62  ifdcs_vectors vs;
63  std::get<0>(vs).push_back(1);
64  std::get<1>(vs).push_back(2.2);
65  std::get<2>(vs).push_back(3.0e-9);
66  std::get<3>(vs).push_back('a');
67  std::get<4>(vs).push_back(std::string("foo"));
68 
69 
70  type_repeater<3, std::string>::type ahahah("one","two","three");
71  std::cerr << std::get<0>(ahahah) << " "
72  << std::get<1>(ahahah) << " "
73  << std::get<2>(ahahah) << "\n";
74 
75 
76 }
hfilts push_back(hfilt)
std::string string
Definition: nybbler.cc:12
#define Assert
Definition: Testing.h:7
const double e
static QCString type
Definition: declinfo.cpp:672
QTextStream & endl(QTextStream &s)