elemental function reverse(self) result(reversed)
!< Return a reversed string.
!<
!<```fortran
!< type(string) :: astring
!< logical :: test_passed(2)
!< astring = 'abcdefghilmnopqrstuvz'
!< test_passed(1) = (astring%reverse()//''=='zvutsrqponmlihgfedcba')
!< astring = '0123456789'
!< test_passed(2) = (astring%reverse()//''=='9876543210')
!< print '(L1)', all(test_passed)
!<```
!=> T <<<
class(string), intent(in) :: self !< The string.
type(string) :: reversed !< The reversed string.
integer :: length !< Length of the string.
integer :: c !< Counter.
if (allocated(self%raw)) then
reversed = self
length = len(self%raw)
do c=1, length
reversed%raw(c:c) = self%raw(length-c+1:length-c+1)
enddo
endif
endfunction reverse