Skip to content

typetraits feature request - get subtype of a generic type #6454

Closed
@mratsim

Description

@mratsim

I need to get the subtype of of generic parameter inside a function. I see that there is a genericHead in typetraits that get the "container". I would love to have a way to get the subtype.

seq[int].genericHead will be just seq

Use case, use TT.genericTail instead of "int" in the following proc

proc Foo[TT](a: TT): array[2, TT] =
  result[0] = newSeq[int](10)

Note this can also be solved with generic generics https://github.com/nim-lang/Nim/issues/3856

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions