c++ - 如何为 boost::units::si::angular_acceleration 赋值?

标签 c++ boost boost-units

在 boost 单元中,我通常通过乘以其中一个静态常量来赋值:

例如

using namespace boost::units;
quantity<si::angular_velocity> av = 0.5 * si::radians_per_second;

但是没有定义乘数常量怎么办呢?

例如这不会编译,因为未定义 boost::units::si::radians_per_second_per_second。

quantity<si::angular_acceleration> aa = 0.5 * si::radians_per_second_per_second;

最佳答案

正如@celtschk 在评论中建议的那样,可以通过对单位乘数应用正确的运算来分配单位:

quantity<si::angular_acceleration> aa = 0.5 * si::radians_per_second / si::seconds;

关于c++ - 如何为 boost::units::si::angular_acceleration 赋值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8796570/

相关文章:

c++ - stdint 类型与 native 类型 : long vs int64_t, int32_t

c++ - 如何为 string_view 创建 (VC14) 调试可视化工具?

c++ - 如何使用 boost 实现这种特定的日期时间格式?

c++ - 使用 Boost.Units 和 Boost.Multiprecision

c++ - 将线性代数库与 Boost::Units 相结合

带有 OpenMP 线程安全随机数的 C++

c++ - 为什么在 C++ 中使用动态分配的内存时我的编译器会报错

c++ - 从字符串中打印出 HTML 标签

c++ - 如何使用 Boost 库序列化结构中的 union ?

c++ - Physical Boost.Units 用户定义文字