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 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /global/management/include/templates.hh (Version 11.3.0) and /global/management/include/templates.hh (Version 3.1)


                                                   >>   1 // This code implementation is the intellectual property of
                                                   >>   2 // the GEANT4 collaboration.
  1 //                                                  3 //
  2 // ******************************************* <<   4 // By copying, distributing or modifying the Program (or any work
  3 // * License and Disclaimer                    <<   5 // based on the Program) you indicate your acceptance of this statement,
  4 // *                                           <<   6 // and all its terms.
  5 // * The  Geant4 software  is  copyright of th <<   7 //
  6 // * the Geant4 Collaboration.  It is provided <<   8 // $Id: templates.hh,v 1.5 2000/01/03 11:39:39 gcosmo Exp $
  7 // * conditions of the Geant4 Software License <<   9 // GEANT4 tag $Name: geant4-03-01 $
  8 // * LICENSE and available at  http://cern.ch/ <<  10 //
  9 // * include a list of copyright holders.      <<  11 // 
 10 // *                                           <<  12 // -*- C++ -*-
 11 // * Neither the authors of this software syst <<  13 //
 12 // * institutes,nor the agencies providing fin <<  14 // -----------------------------------------------------------------------
 13 // * work  make  any representation or  warran <<  15 // This file should define some platform dependent features and some
 14 // * regarding  this  software system or assum <<  16 // useful utilities.
 15 // * use.  Please see the license in the file  <<  17 // -----------------------------------------------------------------------
 16 // * for the full disclaimer and the limitatio <<  18 
 17 // *                                           <<  19 // =======================================================================
 18 // * This  code  implementation is the result  <<  20 // Gabriele Cosmo - Created: 5th September 1995
 19 // * technical work of the GEANT4 collaboratio <<  21 // Gabriele Cosmo - Minor change: 08/02/1996
 20 // * By using,  copying,  modifying or  distri <<  22 // Gabriele Cosmo - Added DBL_MIN, FLT_MIN, DBL_DIG,
 21 // * any work based  on the software)  you  ag <<  23 //                        DBL_MAX, FLT_DIG, FLT_MAX  : 12/04/1996
 22 // * use  in  resulting  scientific  publicati <<  24 // Gabriele Cosmo - Removed boolean enum definition : 29/11/1996
 23 // * acceptance of all terms of the Geant4 Sof <<  25 // Gunter Folger  - Added G4SwapPtr() and G4SwapObj() : 31/07/1997
 24 // ******************************************* <<  26 // Gabriele Cosmo - Adapted signatures of min(), max() to
 25 //                                             <<  27 //                  STL's ones, thanks to E.Tcherniaev : 31/07/1997
 26 // Module defining platform dependent features <<  28 // Gabriele Cosmo,
 27                                                <<  29 // Evgueni Tcherniaev - Migrated to CLHEP: 04/12/1997 
 28 // Author: Gabriele Cosmo, 5 September 1995 -  <<  30 // =======================================================================
 29 // ------------------------------------------- << 
 30 #ifndef templates_hh                           << 
 31 #define templates_hh 1                         << 
 32                                                    31 
 33 #include <climits>                             <<  32 #ifndef templates_h
 34 #include <limits>                              <<  33 #define templates_h 1
 35                                                    34 
                                                   >>  35 //
 36 // If HIGH_PRECISION is defined to TRUE (ie. !     36 // If HIGH_PRECISION is defined to TRUE (ie. != 0) then the type "Float"
 37 // is typedefed to "double". If it is FALSE (i     37 // is typedefed to "double". If it is FALSE (ie. 0) it is typedefed
 38 // to "float".                                     38 // to "float".
 39 //                                                 39 //
 40 #ifndef HIGH_PRECISION                             40 #ifndef HIGH_PRECISION
 41 #  define HIGH_PRECISION 1                     <<  41 #define HIGH_PRECISION 1
 42 #endif                                             42 #endif
 43                                                    43 
 44 #if HIGH_PRECISION                                 44 #if HIGH_PRECISION
 45 using Float = double;                          <<  45 typedef double Float;
 46 #else                                              46 #else
 47 using Float = float;                           <<  47 typedef float Float;
 48 #endif                                             48 #endif
 49                                                    49 
 50 // Following values have been taken from limit     50 // Following values have been taken from limits.h
 51 // and temporarly defined for portability on H     51 // and temporarly defined for portability on HP-UX.
 52                                                    52 
 53 #ifndef DBL_MIN /* Min decimal value of a doub <<  53 #ifndef DBL_MIN   /* Min decimal value of a double */
 54 #  define DBL_MIN std::numeric_limits<double>: <<  54 #define DBL_MIN   2.2250738585072014e-308
 55 #endif                                             55 #endif
 56                                                    56 
 57 #ifndef DBL_DIG /* Digits of precision of a do <<  57 #ifndef DBL_DIG   /* Digits of precision of a double */
 58 #  define DBL_DIG std::numeric_limits<double>: <<  58 #define DBL_DIG   15
 59 #endif                                             59 #endif
 60                                                    60 
 61 #ifndef DBL_MAX /* Max decimal value of a doub <<  61 #ifndef DBL_MAX   /* Max decimal value of a double */
 62 #  define DBL_MAX std::numeric_limits<double>: <<  62 #define DBL_MAX   1.7976931348623157e+308
 63 #endif                                             63 #endif
 64                                                    64 
 65 #ifndef DBL_EPSILON                                65 #ifndef DBL_EPSILON
 66 #  define DBL_EPSILON std::numeric_limits<doub <<  66 #define DBL_EPSILON   2.2204460492503131e-16
 67 #endif  // 2.2204460492503131e-16              << 
 68                                                << 
 69 #ifndef FLT_MIN /* Min decimal value of a floa << 
 70 #  define FLT_MIN std::numeric_limits<float>:: << 
 71 #endif                                             67 #endif
 72                                                    68 
 73 #ifndef FLT_DIG /* Digits of precision of a fl <<  69 #ifndef FLT_MIN   /* Min decimal value of a float */
 74 #  define FLT_DIG std::numeric_limits<float>:: <<  70 #define FLT_MIN   1.17549435e-38F
 75 #endif                                             71 #endif
 76                                                    72 
 77 #ifndef FLT_MAX /* Max decimal value of a floa <<  73 #ifndef FLT_DIG   /* Digits of precision of a float */
 78 #  define FLT_MAX std::numeric_limits<float>:: <<  74 #define FLT_DIG   6
 79 #endif                                             75 #endif
 80                                                    76 
 81 #ifndef FLT_EPSILON                            <<  77 #ifndef FLT_MAX   /* Max decimal value of a float */
 82 #  define FLT_EPSILON std::numeric_limits<floa <<  78 #define FLT_MAX   3.40282347e+38F
 83 #endif  // 1.192092896e-07F                    << 
 84                                                << 
 85 #ifndef MAXFLOAT /* Max decimal value of a flo << 
 86 #  define MAXFLOAT std::numeric_limits<float>: << 
 87 #endif                                             79 #endif
 88                                                    80 
 89 #ifndef INT_MAX /* Max decimal value of a int  <<  81 #ifndef FLT_EPSILON
 90 #  define INT_MAX std::numeric_limits<int>::ma <<  82 #define FLT_EPSILON   1.192092896e-07F
 91 #endif                                         << 
 92                                                << 
 93 #ifndef INT_MIN /* Min decimal value of a int  << 
 94 #  define INT_MIN std::numeric_limits<int>::mi << 
 95 #endif                                             83 #endif
 96                                                    84 
 97 #ifndef LOG_EKIN_MIN /* Min value of the natur <<  85 #ifndef MAXFLOAT   /* Max decimal value of a float */
 98 #  define LOG_EKIN_MIN -30                     <<  86 #define MAXFLOAT   3.40282347e+38F
 99 #endif                                             87 #endif
100                                                    88 
101 //---------------------------------                89 //---------------------------------
102                                                    90 
103 template <class T>                                 91 template <class T>
104 inline void G4SwapPtr(T*& a, T*& b)            <<  92 inline void G4SwapPtr(T* a, T* b) {
105 {                                              <<  93   T* tmp=a;
106   T* tmp = a;                                  <<  94   a = b;
107   a      = b;                                  <<  95   b = tmp;
108   b      = tmp;                                << 
109 }                                              << 
110                                                << 
111 template <class T>                             << 
112 inline void G4SwapObj(T* a, T* b)              << 
113 {                                              << 
114   T tmp = *a;                                  << 
115   *a    = *b;                                  << 
116   *b    = tmp;                                 << 
117 }                                                  96 }
118                                                    97 
119 //-----------------------------                << 
120                                                << 
121 #ifndef G4_SQR_DEFINED                         << 
122 #  define G4_SQR_DEFINED                       << 
123 #  ifdef sqr                                   << 
124 #    undef sqr                                 << 
125 #  endif                                       << 
126                                                << 
127 template <class T>                                 98 template <class T>
128 inline T sqr(const T& x)                       <<  99 inline void G4SwapObj(T* a, T* b) {
129 {                                              << 100   T tmp= *a;
130   return x * x;                                << 101   *a = *b;
131 }                                              << 102   *b = tmp;
132 #endif                                         << 
133                                                << 
134 inline int G4lrint(double ad)                  << 
135 {                                              << 
136   return (int)std::lrint(ad);                  << 
137 }                                                 103 }
138                                                   104 
139 //-----------------------------                   105 //-----------------------------
140                                                   106 
141 //  Use the following function to get rid of " << 107 #endif // templates_h
142 //  Example:                                   << 
143 //                                             << 
144 //      #ifdef SOME_CONDITION                  << 
145 //          void doSomething(int val)          << 
146 //          {                                  << 
147 //              something = val;               << 
148 //          }                                  << 
149 //      #else                                  << 
150 //          void doSomething(int)              << 
151 //          { }                                << 
152 //      #endif                                 << 
153 //                                             << 
154 //  can be simplified to:                      << 
155 //                                             << 
156 //          void doSomething(int val)          << 
157 //          {                                  << 
158 //      #ifdef SOME_CONDITION                  << 
159 //              something = val;               << 
160 //      #else                                  << 
161 //              G4ConsumeParameters(val);      << 
162 //      #endif                                 << 
163 //          }                                  << 
164 //                                             << 
165 //  or:                                        << 
166 //                                             << 
167 //          void doSomething(int val)          << 
168 //          {                                  << 
169 //      #ifdef SOME_CONDITION                  << 
170 //              something = val;               << 
171 //      #endif                                 << 
172 //              // function call does nothing  << 
173 //              G4ConsumeParameters(val);      << 
174 //          }                                  << 
175 //                                             << 
176 template <typename... _Args>                   << 
177 inline void G4ConsumeParameters(_Args&&...)    << 
178 {}                                             << 
179                                                << 
180 #endif  // templates_hh                        << 
181                                                   108