I found a way to deal with the problem finally. We cannot define an template
which return an 'type' (sometime it will fail to compile), but if I return a
variable of the type, it is ok, then I can get the type of the variable.
template get_val_from_item(seq1: untyped): untyped =
var result: type((when compiles(seq1.len): seq1[0] elif seq1 is Slice:
seq1.a else: seq1))
result
template foo1(t: untyped) =
var x: type(get_val_from_item(t))
proc foo[T](x: seq[seq[T]]) =
foo1(x)
echo x
- Compile error when wrapper type(...) with template slangmgh
- Re: Compile error when wrapper type(...) with template slangmgh
- Re: Compile error when wrapper type(...) with template cdome
- Re: Compile error when wrapper type(...) with templ... slangmgh
- Re: Compile error when wrapper type(...) with t... cdome
- Re: Compile error when wrapper type(...) w... slangmgh
- Re: Compile error when wrapper type(..... mashingan
- Re: Compile error when wrapper typ... slangmgh
- Re: Compile error when wrapper typ... LeuGim
- Re: Compile error when wrapper typ... slangmgh
- Re: Compile error when wrapper typ... slangmgh
- Re: Compile error when wrapper typ... LeuGim
