bernedom / SI

A header only C++ library that provides type safety and user defined literals for physical units
https://si.dominikberner.ch/doc/
MIT License
488 stars 40 forks source link

Wrong implementation of comparison operators > and < #43

Closed bladan closed 4 years ago

bladan commented 4 years ago

There seems to be an issue with comparison operators. Following code runs into else() clause.

    auto _SPEED_10_KM_H = 10.0_km / 1.0_h;
    auto _SPEED_80_KM_H = 80.0_km / 1.0_h;
    if (_SPEED_10_KM_H < _SPEED_80_KM_H)
    {
        std::cout << "10 km/h < 80 km/h";
    }
    else
    {
        std::cout << "10 km/h >= 80 km/h";
    }

Reproduced in "SI" version 1.4.1, using clang 7.0.1-8, gcc 8.3.0 and VS2019 16.4.3

bernedom commented 4 years ago

Can confirm, does not work as expected, will investigate. Whoops, this is embarrassing! The operators were implemented the wrong way round and the tests suffered from copy-paste-failure :(

Fixed in 1.5.0