[Feature Request] Keywords for symbol operators

user1234 user1234 at 12.de
Mon Feb 26 11:34:01 UTC 2024


On Monday, 26 February 2024 at 10:57:00 UTC, Danilo wrote:
> On Monday, 26 February 2024 at 10:40:27 UTC, user1234 wrote:
>> [...]
>
> In this case you would need to use cast(bool) like this:
> ```d
> auto and(T,U)(T value1, U value2) => (cast(bool)value1) && 
> (cast(bool)value2);
> ```
> because int does not automatically cast to bool.
>
> Using Steve‘s code, for example:
>
> ```d
> bool and(bool a, bool b) => a && b;
>
> void main() {
>    int foo, bar = 1;
>
>    if(foo.and(bar)) { }
> }
> ```
>
>
> Anyway, the original request was not about UFCS functions.
> The codes are just something to play with, playing with ideas. 
> Nothing useful. ;)

Indeed sorry for the misleading comment. I always forget that 
'bool evaluation' is not an implicit conv.


More information about the Digitalmars-d mailing list