thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
std.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// std.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_std_H
10#define ThePEG_std_H
11
25#include <map>
26#include <set>
27#include <string>
28#include <array>
29#include <vector>
30#include <list>
31#include <iostream>
32#include <fstream>
33#include <sstream>
34#include <iomanip>
35#include <stack>
36#include <utility>
37#include <typeinfo>
38#include <stdexcept>
39#include <cmath>
40
41namespace std {
42
49template <>
50struct less<const type_info *> {
55 typedef type_info first_argument_type;
56 typedef type_info second_argument_type;
57 typedef bool result_type;
58 bool operator()(const type_info * x, const type_info * y) const {
59 return x->before(*y); }
60};
63}
64
65namespace ThePEG {
66
67using std::array;
68using std::deque;
69using std::stack;
70using std::vector;
71using std::multiset;
72using std::set;
73using std::map;
74using std::list;
75using std::multimap;
76using std::pair;
77using std::make_pair;
78using std::less;
79using std::string;
80using std::type_info;
81using std::exception;
82using std::range_error;
83using std::ios;
84using std::ostream;
85using std::istream;
86using std::ofstream;
87using std::ifstream;
88using std::ostringstream;
89using std::istringstream;
90using std::cin;
91using std::cout;
92using std::cerr;
93using std::endl;
94using std::flush;
95using std::setprecision;
96using std::setw;
97using std::swap;
98using std::min;
99using std::max;
100using std::mem_fn;
101//using std::mem_fun;
102using std::sqrt;
103//using std::pow;
104using std::abs;
105using std::atan2;
106using std::isfinite;
107
109template <class ExponentT>
110inline constexpr double pow(double x, ExponentT p) {
111 return std::pow(x,double(p));
112}
113
115inline double sqrt(int x) {
116 return std::sqrt(double(x));
117}
118
120inline constexpr long double factorial(unsigned int n) {
121 return (n < 2) ? 1.0 : n * factorial(n - 1);
122}
123
125template <typename Container, typename Key>
126inline bool member(const Container & c, const Key & k) {
127 return c.find(k) != c.end();
128}
129
131template <typename T, typename Key>
132inline bool member(const vector<T> & v, const Key & k) {
133 for ( typename vector<T>::const_iterator i = v.begin(); i != v.end(); ++i )
134 if ( *i == k ) return true;
135 return false;
136 // return find(v.begin(), v.end(), k) != v.end();
137}
138
140template <typename Cont>
141inline std::insert_iterator<Cont> inserter(Cont & c) {
142 return std::insert_iterator<Cont>(c, c.end());
143}
144
145
148template <typename T, typename A>
149inline std::back_insert_iterator< vector<T,A> > inserter(vector<T,A> & v) {
150 return back_inserter(v);
151}
152
155template <typename T, typename A>
156inline std::back_insert_iterator< deque<T,A> > inserter(deque<T,A> & v) {
157 return back_inserter(v);
158}
159
161inline ostream& left(ostream& os) {
162 os.setf(ios::left, ios::adjustfield);
163 return os;
164}
165
167inline ostream& right(ostream& os) {
168 os.setf(ios::right, ios::adjustfield);
169 return os;
170}
171
172}
173
175#define ThePEG_DECLARE_SET(VALTYPE,NAME) \
176 \
177 typedef set<VALTYPE, less<VALTYPE> > NAME
178
180#define ThePEG_DECLARE_MULTISET(VALTYPE,NAME) \
181 \
182 typedef multiset<VALTYPE, less<VALTYPE> > NAME
183
185#define ThePEG_DECLARE_MAP(KEYTYPE,VALTYPE,NAME) \
186 \
187 typedef map<KEYTYPE, VALTYPE, less<KEYTYPE> > NAME
188
189#endif /* ThePEG_std_H */
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
bool member(const Container &c, const Key &k)
Check if a given object is a part of a container.
Definition: std.h:126
ostream & right(ostream &os)
Stream manipulator setting an ostream to right-adjust its ouput.
Definition: std.h:167
std::insert_iterator< Cont > inserter(Cont &c)
Return an insert iterator for a given container.
Definition: std.h:141
constexpr long double factorial(unsigned int n)
factorial
Definition: std.h:120
ostream & left(ostream &os)
Stream manipulator setting an ostream to left-adjust its ouput.
Definition: std.h:161
STL namespace.
void swap(ThePEG::Pointer::RCPtr< T > &t1, ThePEG::Pointer::RCPtr< T > &t2)
Specialization of std::swap to avoid unnecessary (in/de)crements of the reference count.
Definition: RCPtr.h:1154