11#:include "common.fypp"
2+ #:set IRLC_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES + LOG_KINDS_TYPES + CMPLX_KINDS_TYPES
23!! The module STDLIB_HASHMAP_WRAPPERS provides wrappers for various
34!! entities used by the hash map procedures. These include wrappers for the
45!! `key` and `other` data, and hashing procedures to operate on entities of
@@ -99,6 +100,15 @@ module stdlib_hashmap_wrappers
99100
100101 end interface get
101102
103+  interface get_other_scalar
104+ 
105+  module procedure get_other_scalar_char
106+  #:for k1, t1 in IRLC_KINDS_TYPES
107+  module procedure get_other_scalar_${t1[0]}$${k1}$
108+  #:endfor
109+ 
110+  end interface get_other_scalar
111+ 
102112
103113 interface operator(==)
104114 module procedure equal_keys
@@ -268,28 +278,13 @@ contains
268278
269279 end subroutine get_other
270280
271-  
272-  subroutine get_other_scalar(other, value_char &
273-  #:set IRL_KINDS_TYPES = INT_KINDS_TYPES + REAL_KINDS_TYPES + LOG_KINDS_TYPES
274-  #:for k1, t1 in IRL_KINDS_TYPES
275-  , value_${k1}$ &
276-  #:endfor
277-  #:for k1, t1 in CMPLX_KINDS_TYPES
278-  , value_c${k1}$ &
279-  #:endfor
280-  , exists)
281+  subroutine get_other_scalar_char(other, value, exists)
281282!! Version: Experimental
282283!!
283284!! Gets the content of the other as a scalar of a kind provided by stdlib_kinds
284285!! ([Specifications](../page/specs/stdlib_hashmaps.html#get_other_scalar-extracts-a-scalar-value-from-a-derived-type))
285286 class(other_type), intent(in) :: other
286-  character(len=:), allocatable, intent(out), optional :: value_char
287-  #:for k1, t1 in IRL_KINDS_TYPES
288-  ${t1}$, intent(out), optional :: value_${k1}$
289-  #:endfor
290-  #:for k1, t1 in CMPLX_KINDS_TYPES
291-  ${t1}$, intent(out), optional :: value_c${k1}$
292-  #:endfor
287+  character(len=:), allocatable, intent(out) :: value
293288 logical, intent(out), optional :: exists
294289
295290 logical :: exists_
@@ -303,29 +298,43 @@ contains
303298
304299 select type(d => other % value)
305300 type is ( character(*) )
306-  if (present(value_char)) then
307-  value_char = d
308-  exists_ = .true.
309-  end if
310-  #:for k1, t1 in IRL_KINDS_TYPES
311-  type is ( ${t1}$ )
312-  if (present(value_${k1}$)) then
313-  value_${k1}$ = d
314-  exists_ = .true.
315-  end if
316-  #:endfor
317-  #:for k1, t1 in CMPLX_KINDS_TYPES
301+  value = d
302+  exists_ = .true.
303+  end select
304+ 
305+  if (present(exists)) exists = exists_
306+ 
307+  end subroutine
308+ 
309+  #:for k1, t1 in IRLC_KINDS_TYPES
310+  subroutine get_other_scalar_${t1[0]}$${k1}$(other, value, exists)
311+ !! Version: Experimental
312+ !!
313+ !! Gets the content of the other as a scalar of a kind provided by stdlib_kinds
314+ !! ([Specifications](../page/specs/stdlib_hashmaps.html#get_other_scalar-extracts-a-scalar-value-from-a-derived-type))
315+  class(other_type), intent(in) :: other
316+  ${t1}$, intent(out) :: value
317+  logical, intent(out), optional :: exists
318+ 
319+  logical :: exists_
320+ 
321+  exists_ = .false.
322+ 
323+  if (.not.allocated(other % value)) then
324+  if (present(exists)) exists = exists_
325+  return
326+  end if
327+  
328+  select type(d => other % value)
318329 type is ( ${t1}$ )
319-  if (present(value_c${k1}$)) then
320-  value_c${k1}$ = d
321-  exists_ = .true.
322-  end if
323-  #:endfor
330+  value = d
331+  exists_ = .true.
324332 end select
325333
326334 if (present(exists)) exists = exists_
327335
328336 end subroutine
337+  #:endfor
329338
330339 subroutine get_int8_key( key, value )
331340!! Version: Experimental
0 commit comments