forked from fortran-lang/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdlib_string_type_constructor.fypp
More file actions
35 lines (29 loc) · 1.21 KB
/
Copy pathstdlib_string_type_constructor.fypp
File metadata and controls
35 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#:include "common.fypp"
submodule(stdlib_string_type) stdlib_string_type_constructor
use stdlib_strings, only: to_string
contains
!> Constructor for new string instances from a scalar character value.
elemental module function new_string(string) result(new)
character(len=*), intent(in), optional :: string
type(string_type) :: new
if (present(string)) then
new%raw = string
end if
end function new_string
#:for kind in INT_KINDS
!> Constructor for new string instances from an integer of kind ${kind}$.
elemental module function new_string_from_integer_${kind}$(val) result(new)
integer(${kind}$), intent(in) :: val
type(string_type) :: new
new%raw = to_string(val)
end function new_string_from_integer_${kind}$
#:endfor
#:for kind in LOG_KINDS
!> Constructor for new string instances from a logical of kind ${kind}$.
elemental module function new_string_from_logical_${kind}$(val) result(new)
logical(${kind}$), intent(in) :: val
type(string_type) :: new
new%raw = to_string(val)
end function new_string_from_logical_${kind}$
#:endfor
end submodule stdlib_string_type_constructor