Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-03-13 08:20:26

0001 //  AIDA Detector description implementation 
0002 //--------------------------------------------------------------------------
0003 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0004 // All rights reserved.
0005 //
0006 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0007 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0008 //
0009 //  \author   F.Gaede
0010 //  \date     2015-12-11
0011 //  \version  1.0
0012 //
0013 //==========================================================================
0014 // $Id$
0015 #ifndef DDTEST_SRC_STR_H
0016 #define DDTEST_SRC_STR_H 1
0017 
0018 #include <sstream>
0019 #include <string>
0020 
0021 namespace  {
0022 
0023   template <typename T> std::string _to_string(const T& _val)  {
0024     std::stringstream res; 
0025     res << _val ;
0026     return res.str();
0027   }
0028 
0029   /// Helper class for floating point comparisons using string representations
0030   /**
0031    *  \author  F.Gaede
0032    *  \date    2015-12-11
0033    *  \version 1.0
0034    *
0035    */
0036   class STR {
0037     STR() {} 
0038     float _val ;
0039     std::string _str ;
0040   public:
0041     STR ( float val ) : _val(val), _str(_to_string(val))  {   }
0042     std::string str() const { return _str ; }
0043     float value() const     { return _val;  }
0044     bool operator==( const STR& s2) const {
0045       return this->str() == s2.str() ;
0046     }
0047   };
0048 
0049 
0050   inline std::ostream& operator<<(std::ostream& os , const STR& s) {
0051     os << s.str() ;
0052     return os ;
0053   } 
0054 }
0055 
0056 #endif // DDTEST_SRC_STR_H