in StaticArrays
@generated function (::Type{SArray{S, T, N}})(x::Tuple) where {S <: Tuple, T, N}
return quote
@_inline_meta
SArray{S, T, N, $(tuple_prod(S))}(x)
end
end
I see the use of generated function for outer constructors.
what is the difference (and disadvantage) using the following instead?
SArray{S, T, N}(x::Tuple) where {S<:Tuple, T, N} =
SArray{S, T, N, tuple_prod(S) }(x)
on the other hand, in here:
@inline (::Type{SDiagonal{N,T}})(a::Tuple) where {N,T} = Diagonal(SVector{N,T}(a))
why don’t we define the following?
@inline SDiagonal{N,T}(a::Tuple) where {N,T} = Diagonal(SVector{N,T}(a))
thanks.