thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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
13
14namespace ThePEG {
15
20template <typename T1, typename T2, typename T3>
21struct Triplet {
22
24 typedef T1 first_type;
26 typedef T2 second_type;
28 typedef T3 third_type;
29
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
72template <typename T1, typename T2, typename T3>
73inline Triplet<T1,T2,T3>
74makeTriplet (const T1 & t1, const T2 & t2, const T3 & t3)
75{
76 return Triplet<T1,T2,T3>(t1, t2, t3);
77}
78
80template <typename OStream, typename T1, typename T2, typename T3>
81OStream & operator<<(OStream & os, const Triplet<T1,T2,T3> & t) {
82 return os << t.first << t.second << t.third;
83}
84
86template <typename IStream, typename T1, typename T2, typename T3>
87IStream & 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 */
This is the main config header file for ThePEG.
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
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
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
vector< T > & operator<<(vector< T > &tv, const U &u)
Overload the left shift operator for vector to push_back objects to a vector.
Definition: Containers.h:179
The Triplet class represents a general triplet of objects completely analogous to std::pair.
Definition: Triplet.h:21
Triplet(const Triplet< T1, T2, T3 > &t)
Copy constructor.
Definition: Triplet.h:45
Triplet(const T1 &t1, const T2 &t2, const T3 &t3)
Constructor specifying the three members.
Definition: Triplet.h:41
bool operator<(const Triplet< T1, T2, T3 > &t) const
Test for ordering.
Definition: Triplet.h:62
T3 third_type
The type of the third member.
Definition: Triplet.h:28
T1 first
The first member.
Definition: Triplet.h:31
Triplet()
Default construcotr.
Definition: Triplet.h:38
T2 second_type
The type of the second member.
Definition: Triplet.h:26
bool operator==(const Triplet< T1, T2, T3 > &t) const
Test for equality.
Definition: Triplet.h:54
T2 second
The second member.
Definition: Triplet.h:33
T1 first_type
The type of the first member.
Definition: Triplet.h:24
Triplet(const Triplet< U1, U2, U3 > &u)
Copy constructor from other Triplet type.
Definition: Triplet.h:50
T3 third
The third member.
Definition: Triplet.h:35