determine parameter storage class in D 2.0
Robert Fraser
fraserofthenight at gmail.com
Sun Feb 3 13:28:25 PST 2008
Christian Kamm wrote:
> Has someone figured out a reliable way to determine at compile time whether
> a function parameter is passed by reference or by copy?
>
> The functionality (ParamsPassMethodTuple) in std.bind does not work. (It
> expects that giving a const T to a function expecting ref T will fail,
> which leads to wrong results for simple types like int.)
>
> Modifying it to check with enum T, invariant T or the type's initializer
> fails. I noticed that ParameterTypeTuple!(function) contains the ref/out
> etc. in the tuple, but there seems to be no way to test for it. (stringof
> aside)
>
> Anyway, I think it's odd that for
>
> void foo(ref int i) {}
> void foo2(ParameterTypeTuple!(foo)) {}
>
> ParameterTypeTuple!(foo) is (ref int) and
> ParameterTypeTuple!(foo2) is (int).
>
> Regards,
> Christian Kamm
Looks like a bug
More information about the Digitalmars-d-learn
mailing list