- chrono[meta header]
- std::chrono[meta namespace]
- duration[meta class]
- function[meta id-type]
- cpp11[meta cpp]
duration& operator%=(const rep& rhs); // (1) C++11
constexpr duration& operator%=(const rep& rhs); // (1) C++17
duration& operator%=(const duration& rhs); // (2) C++11
constexpr duration& operator%=(const duration& rhs); // (2) C++17
現在の値をrhs
で割った余りを求める
rep_ %= rhs
rep_ %= rhs.count()
*this
#include <iostream>
#include <chrono>
using std::chrono::duration;
using std::micro;
int main()
{
{
duration<int, micro> d(9);
d %= 2;
std::cout << d.count() << std::endl;
}
{
duration<int, micro> d1(9);
duration<int, micro> d2(2);
d1 %= d2;
std::cout << d1.count() << std::endl;
}
}
- micro[link /reference/ratio/si_prefix.md]
- count()[link count.md]
1
1
- C++11
- GCC: 4.5.1 [mark verified], 4.6.1 [mark verified]
- Visual C++: 2012 [mark verified], 2013 [mark verified], 2015 [mark verified]