std::ratio为度量前缀(centi、deci、deca、hecto)提供了方便的类型。
yocto std::ratio<1, 1000000000000000000000000>, if std::intmax_t can represent the denominator
zepto std::ratio<1, 1000000000000000000000>, if std::intmax_t can represent the denominator
atto std::ratio<1, 1000000000000000000>
femto std::ratio<1, 1000000000000000>
pico std::ratio<1, 1000000000000>
nano std::ratio<1, 1000000000>
micro std::ratio<1, 1000000>
milli std::ratio<1, 1000>
centi std::ratio<1, 100>
deci std::ratio<1, 10>
deca std::ratio<10, 1>
hecto std::ratio<100, 1>
kilo std::ratio<1000, 1>
mega std::ratio<1000000, 1>
giga std::ratio<1000000000, 1>
tera std::ratio<1000000000000, 1>
peta std::ratio<1000000000000000, 1>
exa std::ratio<1000000000000000000, 1>
zetta std::ratio<1000000000000000000000, 1>, if std::intmax_t can represent the numerator
yotta std::ratio<1000000000000000000000000, 1>, if std::intmax_t can represent the numerator 少了什么?好吧..。单位比std::ratio<1,1>。我知道该单位没有正式的公制前缀名称,但这并不意味着它不存在。在[ratio.si]中,没有提到单元前缀。因此,我想知道:使用“单位”比率的最典型方式是什么?例如,当duration_cast-ing转到整秒时。
发布于 2020-10-20 08:49:22
使用“单位”比率最典型的方法是什么?
使用单位比率最实用的方法是不使用它。
这有点像问用1乘的最好方法是什么。你没有。
例如,持续时间为整秒时。
你会写std::chrono::duration_cast<std::chrono::seconds>。
std::ratio<1,1>没有名称,因为您不需要它的名称。例如,std::duration的默认时间段为std::ratio<1,1>。
如果你还想给它起个名字,你可以这样做:
using unit_ratio = std::ratio<1>;https://stackoverflow.com/questions/64440989
复制相似问题