File indexing completed on 2025-01-30 10:11:34
0001
0002
0003
0004
0005
0006
0007 #include <algorithm> // swap()
0008
0009 namespace HepPDT {
0010
0011 inline double NaN() {
0012
0013 struct Dib {
0014 union {
0015 double d;
0016 int i[2];
0017 } u;
0018 };
0019 Dib pos3_2;
0020 Dib posTwo;
0021 pos3_2.u.d = 1.5;
0022 posTwo.u.d = 2.0;
0023 Dib value;
0024 value.u.i[0] = pos3_2.u.i[0] | posTwo.u.i[0];
0025 value.u.i[1] = pos3_2.u.i[1] | posTwo.u.i[1];
0026 return value.u.d;
0027 }
0028
0029
0030 Measurement::Measurement ( double value, double sigma ) :
0031 val(value), sig(sigma) {}
0032
0033 Measurement::Measurement () : val(NaN()), sig(NaN()) {}
0034
0035 Measurement::Measurement ( const Measurement &m ) :
0036 val( m.val ), sig( m.sig ) {}
0037
0038 void Measurement::swap( Measurement & other )
0039 {
0040 std::swap( val, other.val );
0041 std::swap( sig, other.sig );
0042 }
0043
0044 Measurement& Measurement::operator = ( Measurement const & rhs )
0045 {
0046 Measurement temp( rhs );
0047 swap( temp );
0048 return *this;
0049 }
0050
0051 bool Measurement::operator < ( Measurement const & other ) const
0052 {
0053 return val < other.val;
0054 }
0055
0056 bool Measurement::operator == ( Measurement const & other ) const
0057 {
0058 return val == other.val;
0059 }
0060
0061 double Measurement::value() const { return val; }
0062 double Measurement::sigma() const { return sig; }
0063
0064 Measurement::operator double() const { return value(); }
0065
0066
0067 }