mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-21 06:40:06 +08:00
Fix a bug in std::chrono::abs where it would fail when the duration's period had not been reduced.s
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@367120 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1428,7 +1428,7 @@ typename enable_if
|
|||||||
>::type
|
>::type
|
||||||
abs(duration<_Rep, _Period> __d)
|
abs(duration<_Rep, _Period> __d)
|
||||||
{
|
{
|
||||||
return __d >= __d.zero() ? __d : -__d;
|
return __d >= __d.zero() ? +__d : -__d;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -49,5 +49,11 @@ int main(int, char**)
|
|||||||
static_assert(h2.count() == 3, "");
|
static_assert(h2.count() == 3, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Make sure it works for durations that are not LCD'ed - example from LWG3091
|
||||||
|
constexpr auto d = std::chrono::abs(std::chrono::duration<int, std::ratio<60, 100>>{2});
|
||||||
|
static_assert(d.count() == 2, "");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user