print_tupleAs_t.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // test printing for tupleAs
4 //
5 // ======================================================================
6 
9 #include "fhiclcpp/types/Table.h"
10 #include "fhiclcpp/types/TupleAs.h"
11 
12 #include <iostream>
13 #include <string>
14 #include <vector>
15 
16 using namespace fhicl;
17 using namespace std;
18 
19 namespace {
20 
21  struct ThreeNumbers {
22  int i_, j_, k_;
23  ThreeNumbers(int i, int j, int k) : i_{i}, j_{j}, k_{k} {}
24  };
25 
26  struct Person {
27  string name_;
28  unsigned age_{};
29  Person() = default;
30  Person(string name, unsigned age) : name_{name}, age_{age} {}
31  };
32 
33  struct ToVector {
34 
35  ToVector(int j, std::vector<int> const& v)
36  {
37  for (auto number : v)
38  value_.push_back(j * number);
39  }
40 
41  std::vector<int> value_;
42  };
43 
44  std::ostream&
45  operator<<(std::ostream& os, Person const& p)
46  {
47  return os << "Name: " << p.name_ << " Age: " << p.age_;
48  }
49 
50  struct Config {
52  Comment("Vector for Geant")};
54  ThreeNumbers{1, 3, 5}};
56  TupleAs<Person(string, unsigned)> person2{Name("person2"),
57  Person{"Jon", 97}};
60  };
61 }
62 
63 int
65 {
66  fhicl::Table<Config> const config{Name("pset")};
67  config.print_allowed_configuration(cout);
68 }
static QCString name
Definition: declinfo.cpp:673
ChannelGroupService::Name Name
::geo::Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
STL namespace.
typename config_impl< T >::type Config
Definition: ModuleMacros.h:52
static Config * config
Definition: config.cpp:1054
p
Definition: test.py:223
#define Comment
std::ostream & operator<<(std::ostream &, ParameterSetID const &)