@@ -1972,3 +1972,58 @@ program demo
19721972 close(io)
19731973end program demo
19741974```
1975+
1976+
1977+ <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
1978+ ### move
1979+
1980+ #### Description
1981+
1982+ Moves the allocation from ` from ` to ` to ` , consequently deallocating ` from ` in this process.
1983+ If ` from ` is not allocated before execution, ` to ` gets deallocated by the process.
1984+ An unallocated ` string_type ` instance is equivalent to an empty string.
1985+
1986+ #### Syntax
1987+
1988+ ` call [[stdlib_string_type(module):move(interface)]] (from, to) `
1989+
1990+ #### Status
1991+
1992+ Experimental
1993+
1994+ #### Class
1995+
1996+ Pure Subroutine.
1997+
1998+ #### Argument
1999+
2000+ - ` from ` : Character scalar or [[ stdlib_string_type(module): string_type (type)]] .
2001+ This argument is ` intent(inout) ` .
2002+ - ` to ` : Character scalar or [[ stdlib_string_type(module): string_type (type)]] .
2003+ This argument is ` intent(out) ` .
2004+
2005+ #### Example
2006+
2007+ ``` fortran
2008+ program demo_move
2009+ use stdlib_string_type, only : string_type, assignment(=), move
2010+ implicit none
2011+ type(string_type) :: from_string
2012+ character(len=:), allocatable :: from_char, to_char
2013+
2014+ from_string = "move this string"
2015+ from_char = "move this char"
2016+ ! from_string <-- "move this string"
2017+ ! from_char <-- "move this char"
2018+ ! to_char <-- (unallocated)
2019+
2020+ call move(from_string, to_char)
2021+ ! from_string <-- ""
2022+ ! to_char <-- "move this string"
2023+
2024+ call move(from_char, to_char)
2025+ ! from_char <-- (unallocated)
2026+ ! to_string <-- "move this char"
2027+
2028+ end program demo_move
2029+ ```
0 commit comments