私はこれが適切にコンパイルされることを期待していました:
#include <boost/test/unit_test.hpp>
#include <boost/units/quantity.hpp>
#include <boost/units/systems/angle/degrees.hpp>
using boost::units::quantity;
using boost::units::degree::degrees;
using boost::units::degree::plane_angle;
int main() {
quantity<plane_angle> q1 = 15 * degrees;
BOOST_CHECK_CLOSE(q1, 15 * degrees, 1e-8);
return 0;
}
残念ながら、これにより GCC で数百行のエラーが発生します。
もちろん、代わりにこれを行うこともできます。
BOOST_CHECK_CLOSE(q1.value(), 15, 1e-8);
しかし、他の誰かが のユニット タイプを変更することを決定した場合に備えて、テスト ケースでユニットを明示的に保持したいと思いますq1
。
単位を明示的に保つ方法はありますか?