On Saturday, 16 March 2024 at 15:50:27 UTC, Walter Bright wrote:
>Thanks. Having a look:
>But const X!(int*)
will instantiate bar
as void bar(int*)
.
Nope. It will instantiate it as void bar(int*) const
.
The template struct or template class will be treated as a list of its members.
Three points.
-
Why wouldn't this apply only to templated structs? It'd make sense for the rules to apply to all structs/classes.
-
In the presented example, no fields are actually converted. The only field,
x
, is the same type in both cases (const(int[])
). Please add an example where type of the field(s) differ, say convertingX!(immutable(int))
toconst(X!int)
. -
Could allowing these casts break assumptions of a type that has
@system
fields (DIP1035)? I haven't thought it deeply enough to conclude one way pr another but the DIP should probably explain it.
Only members that are fields or non-static functions are considered.
I don't see why member functions would need to be considered, static or no. An instance of a struct doesn't contain it's member functions as fields.