character_concat_string Function

private pure function character_concat_string(lhs, rhs) result(concat)

Concatenation with character (inverted).

 type(string)                  :: astring
 character(len=:), allocatable :: acharacter
 logical                       :: test_passed(1)
 astring = 'Hello '
 acharacter = 'World!'
 test_passed(1) = acharacter//astring=='World!Hello '
 print '(L1)', all(test_passed)

Type Bound

string

Arguments

Type IntentOptional Attributes Name
character(kind=CK, len=*), intent(in) :: lhs

Left hand side.

class(string), intent(in) :: rhs

Right hand side.

Return Value character(kind=CK, len=:), allocatable

Concatenated string.


Contents


Source Code

   pure function character_concat_string(lhs, rhs) result(concat)
   !< Concatenation with character (inverted).
   !<
   !<```fortran
   !< type(string)                  :: astring
   !< character(len=:), allocatable :: acharacter
   !< logical                       :: test_passed(1)
   !< astring = 'Hello '
   !< acharacter = 'World!'
   !< test_passed(1) = acharacter//astring=='World!Hello '
   !< print '(L1)', all(test_passed)
   !<```
   !=> T <<<
   character(kind=CK, len=*), intent(in)  :: lhs    !< Left hand side.
   class(string),             intent(in)  :: rhs    !< Right hand side.
   character(kind=CK, len=:), allocatable :: concat !< Concatenated string.

   if (allocated(rhs%raw)) then
      concat = lhs//rhs%raw
   else
      concat = lhs
   endif
   endfunction character_concat_string