Mercurial > repos > public > sbplib_julia
diff src/Grids/grid.jl @ 1270:dcbac783e4c1 refactor/grids
Factor out functions for getting the type and number of components in a type
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 25 Feb 2023 22:42:16 +0100 |
parents | 20f42cf0800c |
children | 3637daad71e8 |
line wrap: on
line diff
--- a/src/Grids/grid.jl Sat Feb 25 22:22:50 2023 +0100 +++ b/src/Grids/grid.jl Sat Feb 25 22:42:16 2023 +0100 @@ -64,3 +64,11 @@ # Should it be lazy? Could it be a view? function getcomponent(gfun, I::Vararg{Int}) end # function getcomponent(gfun, s::Symbol) end ? + + +# TODO: Explain how these are intended to be used +_ncomponents(::Type{<:Number}) = 1 +_ncomponents(T::Type{<:SVector}) = length(T) + +_component_type(T::Type{<:Number}) = T +_component_type(T::Type{<:SVector}) = eltype(T)