Skip to content

operator/(duration, duration) has wrong return type #554

@mtnpke

Description

@mtnpke

operator/ with two durations as arguments is implemented to return a duration:

template <typename Rep1, typename Period1, typename Rep2, typename Period2>
typename eastl::common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type EASTL_FORCE_INLINE
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs)
{
typedef typename eastl::common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type common_duration_t;
return common_duration_t(common_duration_t(lhs).count() / common_duration_t(rhs).count());
}

This is wrong; see https://en.cppreference.com/w/cpp/chrono/duration/operator_arith4 (6) - "Note that the return value of this operator is not a duration."

Divison of two durations should return a dimensionless number and not a duration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions