Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -3387,14 +3387,16 @@ namespace chrono {
if constexpr (_Can_rep_sec) {
if (_Used & _F_sec) {
if (_Subsecond) {
using _CastedType = duration<int64_t, typename _DurationType::period>;
const _SubsecondType _Sub{*_Subsecond};
if (treat_as_floating_point_v<_DurationType> //
|| _CHRONO duration_cast<_CastedType>(_Sub) == _Sub) {
_Result += _CHRONO duration_cast<_DurationType>(_Sub);
} else {
return false;

if constexpr (!treat_as_floating_point_v<typename _DurationType::rep>) {
using _CastedType = duration<int64_t, typename _DurationType::period>;
if (_CHRONO duration_cast<_CastedType>(_Sub) != _Sub) {
return false;
}
}

_Result += _CHRONO duration_cast<_DurationType>(_Sub);
}

if (_Second) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ void parse_seconds() {
test_parse("0.400000000000000002", "%S", time_atto);
assert((time_atto == duration<int64_t, deci>{4} + duration<int64_t, atto>{2}));

duration<float, ratio<1, 25>> time_float;
test_parse("0.33", "%S", time_float);
assert((time_float == duration<float, ratio<1, 25>>{8.25f}));

fail_parse("1.2 1.3", "%S %S", time_ms);
fail_parse("1.2 2.2", "%S %S", time_ms);
}
Expand Down