Sukera
October 23, 2022, 11:20am
5
This has been discussed numerous times - search for “strip type parameters” .
This is the most relevant result:
I have writing code that maniuplates containers of arrays of custom types with several parameters, e.g.
SomeArrayType{T, G1, G2, N} <: AbstractArray{T, N}, where the last parameter in SomeArrayType is always the array rank N. The arrays that can be in the container can differ in rank N but otherwise should be the same type, for example Vector{SomeArray{T, G1, G2}} which can also be written Vector{SomeArray{T, G1, G2, N} where N}.
I’d like to create a function arraytype that strips the last (ra…
uniment:
I’d like to call its constructor while discarding its parameters, in order to call it with different parameters, e.g. Test{3,4}()
.
There may not be such a constructor. This is not safe to do in general. Reflection can only work in limited cases here. The “canonical” solution is to have similar
implemented on your type.
1 Like