Doubt about char.min/max == typeid(char)

ag0aep6g anonymous at example.com
Fri Oct 7 06:09:22 UTC 2022


On 07.10.22 07:06, bauss wrote:
> If you don't need to assign it then you can cast it.
> 
> ```
> void a(int x) { ... }
> 
> a(cast(int)char.max);
> ```
> 
> Even though in the example above the cast isn't necessary, if you want 
> to be sure a(int) is called then you must cast it, since an overload of 
> char will obviously be picked.

You can also do that without a cast:

     a(int(char.max));

Does the same thing of course, but it's less dangerous than casting.


More information about the Digitalmars-d-learn mailing list