File indexing completed on 2025-03-13 08:20:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
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
0030
0031
0032
0033
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