Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-06 09:38:20

0001 // -*- C++ -*-
0002 //
0003 // std.h is a part of ThePEG - Toolkit for HEP Event Generation
0004 // Copyright (C) 1999-2019 Leif Lonnblad
0005 //
0006 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
0007 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
0008 //
0009 #ifndef ThePEG_std_H
0010 #define ThePEG_std_H
0011 
0012 /** \file
0013 
0014  * This file introduces a number of <code>std::</code> classes into
0015  * the ThePEG namespace. Also introduces some useful functions for
0016  * standard library classes.
0017  *
0018  * Do not make changes in this file. If you want to use alternatives
0019  * to the <code>std::</code> classes in ThePEG, edit a copy of this
0020  * file and include it in an alternative config file which can be
0021  * included in the main ThePEG.h config file using the macro
0022  * <code>ThePEG_ALTERNATE_CONFIG</code>.
0023  */
0024 
0025 #include <map>
0026 #include <set>
0027 #include <string>
0028 #include <array>
0029 #include <vector>
0030 #include <list>
0031 #include <iostream>
0032 #include <fstream>
0033 #include <sstream>
0034 #include <iomanip>
0035 #include <stack>
0036 #include <utility>
0037 #include <typeinfo>
0038 #include <stdexcept>
0039 #include <cmath>
0040 
0041 namespace std {
0042 
0043 /** @cond TRAITSPECIALIZATIONS */
0044 /**
0045  * This specialization of the std::less class is needed in order to be
0046  * able use put pointers to type_info objects as keys in maps and
0047  * sets.
0048  */
0049 template <>
0050 struct less<const type_info *> {
0051   /**
0052    * This is the function called when comparing two pointers to
0053    * type_info.
0054    */
0055   typedef type_info first_argument_type;
0056   typedef type_info second_argument_type;
0057   typedef bool result_type;
0058   bool operator()(const type_info * x, const type_info * y) const {
0059     return x->before(*y); }
0060 };
0061 /** @endcond */
0062 
0063 }
0064 
0065 namespace ThePEG {
0066 
0067 using std::array;
0068 using std::deque;
0069 using std::stack;
0070 using std::vector;
0071 using std::multiset;
0072 using std::set;
0073 using std::map;
0074 using std::list;
0075 using std::multimap;
0076 using std::pair;
0077 using std::make_pair;
0078 using std::less;
0079 using std::string;
0080 using std::type_info;
0081 using std::exception;
0082 using std::range_error;
0083 using std::ios;
0084 using std::ostream;
0085 using std::istream;
0086 using std::ofstream;
0087 using std::ifstream;
0088 using std::ostringstream;
0089 using std::istringstream;
0090 using std::cin;
0091 using std::cout;
0092 using std::cerr;
0093 using std::endl;
0094 using std::flush;
0095 using std::setprecision;
0096 using std::setw;
0097 using std::swap;
0098 using std::min;
0099 using std::max;
0100 using std::mem_fn;
0101 using std::mem_fun;
0102 using std::sqrt;
0103 //using std::pow;
0104 using std::abs;
0105 using std::atan2;
0106 using std::isfinite;
0107 
0108 /** Powers - standard or non-standard */
0109 template <class ExponentT>
0110 inline constexpr double pow(double x, ExponentT p) {
0111   return std::pow(x,double(p));
0112 }
0113 
0114 /** Square root of an integer. */
0115 inline double sqrt(int x) {
0116   return std::sqrt(double(x));
0117 }
0118 
0119 /** factorial */
0120 inline constexpr long double factorial(unsigned int n) {
0121   return (n < 2) ? 1.0 : n * factorial(n - 1);
0122 }
0123 
0124 /** Check if a given object is a part of a container. */
0125 template <typename Container, typename Key>
0126 inline bool member(const Container & c, const Key & k) {
0127   return c.find(k) != c.end();
0128 }
0129 
0130 /** Check if a given object is a part of a vector. */
0131 template <typename T, typename Key>
0132 inline bool member(const vector<T> & v, const Key & k) {
0133   for ( typename vector<T>::const_iterator i = v.begin(); i != v.end(); ++i )
0134     if ( *i == k ) return true;
0135   return false;
0136   // return find(v.begin(), v.end(), k) != v.end();
0137 }
0138 
0139 /** Return an insert iterator for a given container. */
0140 template <typename Cont>
0141 inline std::insert_iterator<Cont> inserter(Cont & c) {
0142   return std::insert_iterator<Cont>(c, c.end());
0143 }
0144 
0145 
0146 /** Return an insert iterator for a given vector. Overrides the
0147  *  general version. */
0148 template <typename T, typename A>
0149 inline std::back_insert_iterator< vector<T,A> > inserter(vector<T,A> & v) {
0150   return back_inserter(v);
0151 }
0152 
0153 /** Return an insert iterator for a given vector. Overrides the
0154  *  general version. */
0155 template <typename T, typename A>
0156 inline std::back_insert_iterator< deque<T,A> > inserter(deque<T,A> & v) {
0157   return back_inserter(v);
0158 }
0159 
0160 /** Stream manipulator setting an ostream to left-adjust its ouput. */
0161 inline ostream& left(ostream& os) {
0162   os.setf(ios::left, ios::adjustfield);
0163   return os;
0164 }
0165 
0166 /** Stream manipulator setting an ostream to right-adjust its ouput. */
0167 inline ostream& right(ostream& os) {
0168   os.setf(ios::right, ios::adjustfield);
0169   return os;
0170 }
0171 
0172 }
0173 
0174 /** Macro for declaring a set. */
0175 #define ThePEG_DECLARE_SET(VALTYPE,NAME)                               \
0176   /** A set of VALTYPE. */                                             \
0177   typedef set<VALTYPE, less<VALTYPE> > NAME
0178 
0179 /** Macro for declaring a multiset. */
0180 #define ThePEG_DECLARE_MULTISET(VALTYPE,NAME)                          \
0181   /** A multiset of VALTYPE. */                                        \
0182   typedef multiset<VALTYPE, less<VALTYPE> > NAME
0183 
0184 /** Macro for declaring a map. */
0185 #define ThePEG_DECLARE_MAP(KEYTYPE,VALTYPE,NAME)                       \
0186   /** A map of VALTYPE indexed by KEYTYPE. */                          \
0187   typedef map<KEYTYPE, VALTYPE, less<KEYTYPE> > NAME
0188 
0189 #endif /* ThePEG_std_H */