Consider the following toy example:
module test_module implicit none type :: myint integer :: i = 0 contains generic :: assignment(=) => int_to_myint procedure :: int_to_myint end type myint contains subroutine int_to_myint(me,i) !myint = integer assignment implicit none class(myint),intent(inout) :: me integer,intent(in) :: i me%i = i end subroutine int_to_myint end module test_module
The type(myint)=integer assignment works great. My question is this: is it possible to have the reverse assignment (integer=type(myint)) work as well? This would be like overloading the assignment operator for the integer type, I guess? Is such a thing possible?