sun::ast::VariadicParam
struct · Source (opens in a new tab)
struct sun::ast::VariadicParamThe trailing value pack in a parameter list, as written at the end of the parentheses: a name, and the type annotation after its colon.
args... name "args", anything the call supplies args...: _params_of<T> the parameters T's init takes, or, when T is a lambda, the parameters that lambda takes
The annotation sits where an ordinary parameter's type sits, but it stands for a whole parameter list rather than one type, and the call's arguments are checked against it. It is not a constraint in the <T: _Numeric> sense: it does not narrow which types are allowed, it says where the pack's parameters come from.
A pack is not a type. It stands for however many arguments the call passes, so a declaration holding one is a template: it is monomorphized once per argument tuple, and the pack's elements become ordinary positional parameters named args.0, args.1, … in that specialization.
Public Functions
VariadicParam
VariadicParam()=default
public · function · Source (opens in a new tab)
sun::ast::VariadicParam::VariadicParam()=defaultCreates a variadic parameter with its optional element annotation.
VariadicParam(std::string n, std::optional< TypeAnnotation > annot=std::nullopt)
public · function · Source (opens in a new tab)
sun::ast::VariadicParam::VariadicParam(std::string n, std::optional< TypeAnnotation > annot=std::nullopt)Creates a variadic parameter with its optional element annotation.
Related: TypeAnnotation
elementName
public · function · Source (opens in a new tab)
std::string sun::ast::VariadicParam::elementName(size_t i) constThe element the pack materializes as at index i, e.g.
args.0. Codegen names the specialization's parameters this way and semantic analysis rewrites args... into references to exactly these names, so the two sides must agree here and nowhere else.
hasTypeAnnotation
public · function · Source (opens in a new tab)
bool sun::ast::VariadicParam::hasTypeAnnotation() constReports whether this object has type annotation.
Public Fields
name
public · variable · Source (opens in a new tab)
std::string sun::ast::VariadicParam::nameNo documentation comment.
typeAnnotation
public · variable · Source (opens in a new tab)
std::optional<TypeAnnotation> sun::ast::VariadicParam::typeAnnotationNo documentation comment.
Related: TypeAnnotation