thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
Triplet.h
1 // -*- C++ -*-
2 //
3 // Triplet.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_Triplet_H
10 #define ThePEG_Triplet_H
11 
12 #include "ThePEG/Config/ThePEG.h"
13 
14 namespace ThePEG {
15 
20 template <typename T1, typename T2, typename T3>
21 struct Triplet {
22 
24  typedef T1 first_type;
26  typedef T2 second_type;
28  typedef T3 third_type;
29 
31  T1 first;
33  T2 second;
35  T3 third;
36 
38  Triplet() : first(T1()), second(T2()), third(T3()) {}
39 
41  Triplet(const T1 & t1, const T2 & t2, const T3 & t3)
42  : first(t1), second(t2), third(t3) {}
43 
46  : first(t.first), second(t.second), third(t.third) {}
47 
49  template <typename U1, typename U2, typename U3>
51  : first(u.first), second(u.second), third(u.third) {}
52 
54  bool operator==(const Triplet<T1,T2,T3> & t) const {
55  return first == t.first && second == t.second && third == t.third;
56  }
57 
62  bool operator<(const Triplet<T1,T2,T3> & t) const {
63  return first < t.first ||
64  ( !(t.first < first) &&
65  ( second < t.second ||
66  ( !(t.second < second) && third < t.third )));
67  }
68 };
69 
72 template <typename T1, typename T2, typename T3>
73 inline Triplet<T1,T2,T3>
74 makeTriplet (const T1 & t1, const T2 & t2, const T3 & t3)
75 {
76  return Triplet<T1,T2,T3>(t1, t2, t3);
77 }
78 
80 template <typename OStream, typename T1, typename T2, typename T3>
81 OStream & operator<<(OStream & os, const Triplet<T1,T2,T3> & t) {
82  return os << t.first << t.second << t.third;
83 }
84 
86 template <typename IStream, typename T1, typename T2, typename T3>
87 IStream & operator>>(IStream & is, Triplet<T1,T2,T3> & t) {
88  return is >> t.first >> t.second >> t.third;
89 }
90 
91 }
92 
93 #endif /* ThePEG_Triplet_H */
Triplet()
Default construcotr.
Definition: Triplet.h:38
Triplet(const Triplet< T1, T2, T3 > &t)
Copy constructor.
Definition: Triplet.h:45
T3 third_type
The type of the third member.
Definition: Triplet.h:28
T2 second
The second member.
Definition: Triplet.h:33
T1 first_type
The type of the first member.
Definition: Triplet.h:24
T3 third
The third member.
Definition: Triplet.h:35
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
This is the main config header file for ThePEG.
Triplet(const T1 &t1, const T2 &t2, const T3 &t3)
Constructor specifying the three members.
Definition: Triplet.h:41
Triplet(const Triplet< U1, U2, U3 > &u)
Copy constructor from other Triplet type.
Definition: Triplet.h:50
T2 second_type
The type of the second member.
Definition: Triplet.h:26
vector< T > & operator>>(vector< T > &tv, U &u)
Overload the right shift operator for vector to pop objects from a vector.
Definition: Containers.h:192
Triplet< T1, T2, T3 > makeTriplet(const T1 &t1, const T2 &t2, const T3 &t3)
Helper function returning a Triplet with template parameters determined by the arguments.
Definition: Triplet.h:74
bool operator==(const Triplet< T1, T2, T3 > &t) const
Test for equality.
Definition: Triplet.h:54
The Triplet class represents a general triplet of objects completely analogous to std::pair...
Definition: Triplet.h:21
T1 first
The first member.
Definition: Triplet.h:31