Skip to content

user_rounding_error template signature #834

@mjhilt

Description

@mjhilt

In policies/error_handling.hpp the user_rounding_error template signature is currently defined as

template <class T, class TargetType>
T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);

And then it is used in

template <class T, class TargetType>
inline TargetType raise_rounding_error(
           const char* function,
           const char* message,
           const T& val,
           const TargetType& t,
           const  ::boost::math::policies::rounding_error< ::boost::math::policies::user_error>&)
{
   return user_rounding_error(function, message, val, t);  // <---- note the implicit cast from T to TargetType here
}

The implicit cast hints that this might not be the intended use of the user defined function (perhaps result of a copy/paste error)? I would guess the correct signature would be to return a TargetType instead.

If I'm incorrect and the intention really is for a cast to take place there, can you add a static_cast-like wrapper so compliers don't complain about possible loss of precision (which is how I found this in the first place)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions