Implicit conversion to mutable if no indirections?
Steven Schveighoffer
schveiguy at gmail.com
Sat Sep 3 14:43:41 UTC 2022
On 9/3/22 10:15 AM, Nick Treleaven wrote:
> On Saturday, 3 September 2022 at 01:50:05 UTC, Steven Schveighoffer wrote:
>> It's not just that, there is no syntax to say to IFTI, "if you match
>> type T, I really want you to use type U". It would actually be nice,
>> but I don't know how it can be done.
>
> The following works, the pragma only prints once.
>
> ```d
> void f(T)(const T v)
> {
> pragma(msg, T); // int
> T result;
> ++result;
> }
>
> void main()
> {
> const int c;
> f(c);
> f(int());
> }
> ```
This solves the OP's problem, but I am certain that is just a toy
example. What I want to see is the *parameter* properly typed. Either
left as const if it's a reference type or stripped of const if it's a
value type.
-Steve
More information about the Digitalmars-d
mailing list