以度数定义 boost::units 角度

define a boost::units angle in degrees

如何以度数定义增强单位角度?下面显示有效的弧度和无效的度数。

#include <boost/units/unit.hpp>
#include <boost/units/systems/si/io.hpp>
#include <boost/units/systems/angle/degrees.hpp>

// This works for defining an angle in radians
boost::units::quantity<
    boost::units::unit<
        boost::units::plane_angle_dimension,
        boost::units::si::system
    >
> my_angle_radians(2.0 * boost::units::si::radian);

// This is what I'm trying to do that doesn't work
boost::units::quantity<
    boost::units::unit<
        boost::units::plane_angle_dimension,
        boost::units::degree::system
    >
> my_angle_degree(2.0 * boost::units::angle::degree_base_unit);

使用boost::units::degree::degree:

my_angle_degree(2.0 * boost::units::degree::degree);

两条线

BOOST_UNITS_STATIC_CONSTANT(degree,plane_angle);
BOOST_UNITS_STATIC_CONSTANT(degrees,plane_angle);

成为boost::units::degree命名空间中的这两个静态常量:

static const plane_angle degree;
static const plane_angle degrees;