- chrono[meta header]
- std::chrono[meta namespace]
- function template[meta id-type]
- cpp11[meta cpp]
namespace std {
namespace chrono {
template <class Rep1, class Period1, class Rep2, class Period2>
constexpr typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
operator-(const duration<Rep1, Period1>& lhs,
const duration<Rep2, Period2>& rhs); // (1) C++11
}}- common_type[link /reference/chrono/common_type.md]
durationの減算を行う
- (1)
using cd = common_type<decltype(lhs), decltype(rhs)>;
return cd(cd(lhs).count() - cd(rhs).count());- common_type[link /reference/chrono/common_type.md]
- count()[link count.md]
#include <iostream>
#include <chrono>
using namespace std::chrono;
int main()
{
seconds s = seconds{3} - seconds{2};
std::cout << s.count() << std::endl;
milliseconds ms = seconds{3} - milliseconds{2};
std::cout << ms.count() << std::endl;
}- count()[link count.md]
1
2998
- C++11
- Clang: 3.2 [mark verified]
- GCC: 4.6.1 [mark verified]
- Visual C++: 2012 [mark verified], 2013 [mark verified], 2015 [mark verified]