Skip to content

Generic procedure including a sub-class of TimeDelta #61

@dtokuda

Description

@dtokuda

I faced a problem with a sub-class of timedelta.
I defined a generic procedure name for operator(+) (as below, can be compiled),
but the program executes the operator for TimeDelta, not for RelativeDelta.

type, extends(TimeDelta) :: RelativeDelta
***
end type RelativeDelta

interface operator(+)
    module procedure datetime_plus_relativedelta
    module procedure relativedelta_plus_datetime
end interface operator(+)

One possible reason is class in the original datetime_plus_timedelta function.
While type(timedelta) indicates only timedelta class, class(timedelta) does sub-classes in addition to timedelta class.

pure elemental function datetime_plus_timedelta(d0,t) result(d)
  class(datetime), intent(in) :: d0 !! `datetime` instance
  class(timedelta),intent(in) :: t  !! `timedelta` instance

Could you update the attribute from class to type in non-method procedures?
Or what can I do for overloading of such a function?
I will appreciate your help with this issue.

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