Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JTuple.cc File Reference

Example program to test JTOOLS::JTuple class. More...

#include <iostream>
#include <iomanip>
#include "JTools/JTuple.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JTOOLS::JTuple class.

Author
mdejong

Definition in file JTuple.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file JTuple.cc.

18 {
19  using namespace std;
20 
21  int debug;
22 
23  try {
24 
25  JParser<> zap("Example program to test tuple class.");
26 
27  zap['d'] = make_field(debug) = 3;
28 
29  zap(argc, argv);
30  }
31  catch(const exception &error) {
32  FATAL(error.what() << endl);
33  }
34 
35 
36  using namespace JPP;
37 
38  {
40 
41  JTuple<typelist> A(+1, +2, +0.9999);
42  JTuple<typelist> B(-A);
43 
44  cout << A.first << endl;
45  cout << A.second.first << endl;
46  cout << A.second.second << endl;
47 
48  cout << "A = " << showpos << A << endl;
49  cout << "B = " << showpos << B << endl;
50  cout << "A + B = " << noshowpos << A+B << endl;
51 
52  cout << "A == A ? " << (A == A) << endl;
53  cout << "A == B ? " << (A == B) << endl;
54  }
55 
56  {
57  typedef JTYPELIST<string, int>::typelist typelist;
58 
59  JTuple<typelist> A;
60  JTuple<typelist> B;
61 
62  A.first = "aap";
63  A.second = 1234;
64 
65  B.first = "noot";
66  B.second = -A.second;
67 
68  cout << "A = " << A << endl;
69  cout << "B = " << B << endl;
70  cout << "A + B = " << A+B << endl; // uses std::string operator::+=()
71  cout << "A == A ? " << (A == A) << endl;
72  cout << "A == B ? " << (A == B) << endl;
73  }
74 
75  {
76  cout << JPP::make_tuple(1, string("aap"), 0.99) << endl;
77  }
78 }
Utility class to parse command line options.
Definition: JParser.hh:1410
Type list.
Definition: JTypeList.hh:22
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1836
int debug
debug level
Definition: JSirene.cc:59
#define FATAL(A)
Definition: JMessage.hh:65
JTuple< JTypeList< JNullType, JNullType > > make_tuple(const JNullType &b, const JNullType &c, const JNullType &d, const JNullType &e, const JNullType &f, const JNullType &g, const JNullType &h, const JNullType &i, const JNullType &j, const JNullType &k, const JNullType &l, const JNullType &m, const JNullType &n, const JNullType &o, const JNullType &p, const JNullType &q, const JNullType &r, const JNullType &s, const JNullType &t, const JNullType &u, const JNullType &v, const JNullType &w, const JNullType &x, const JNullType &y, const JNullType &z)
Helper method for tuple.
Definition: JTuple.hh:724