We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
string
move
2 parents 8476d65 + 9703a80 commit 7211ce8Copy full SHA for 7211ce8
src/stdlib_string_type.fypp
@@ -679,12 +679,13 @@ contains
679
!> Moves the allocated character scalar from 'from' to 'to'
680
!> No output
681
elemental subroutine move_string_string(from, to)
682
- type(string_type), intent(inout) :: from
683
- type(string_type), intent(inout) :: to
684
- character(:), allocatable :: tmp
+ type(string_type), intent(inout), target :: from
+ type(string_type), intent(inout), target :: to
+ type(string_type), pointer :: fromp
685
686
- call move_alloc(from%raw, tmp)
687
- call move_alloc(tmp, to%raw)
+ fromp => from
+ if (associated(fromp,to)) return
688
+ call move_alloc(from%raw, to%raw)
689
690
end subroutine move_string_string
691
0 commit comments