Millimeters in boost::units

后端 未结 3 1526
鱼传尺愫
鱼传尺愫 2021-01-05 09:55

I want to use boost::units for some SI metrics. However our code mostly deals with millimeters and instead of using

quantity value = 1*milli*m         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-05 10:47

    If you have a C++11 capable compiler you could use User Defined Literals for defining your units.

    double operator"" _millimeter ( double value )
    {
        return value;
    }
    

    You can use that like so:

    double foo = 1000_millimeter;
    

提交回复
热议问题