On Thursday, 25 July 2024 at 14:05:50 UTC, Dom DiSc wrote:
As he said: no. It's only true for @safe:

No they did not, they specifically said that my assertion holds true for all other [function attributes](https://dlang.org/spec/attribute.html#function-attributes). This does not tell me anything about other attributes like `align`, `deprecated`, `@__future`, linkage attributes, visibility attributes, mutability attributes, shared storage attributes, `@system` variables, or UDAs.

But that doesn't answer my question.

Your question was ‘Can I replace this pattern with `(x is this)`’. The answer is no.

You said it is not the same. But then: is there another way to translate the C++ pattern in a @safe way?

This is the first time you have mentioned this intention with words. I’m not a mind reader. I think your function most likely has a safe interface, so it can be marked as `@trusted` as-per [the spec](https://dlang.org/spec/function.html#safe-interfaces). Let’s go through the checklist: - undefined behaviour? Nothing undefined about comparing two numbers. - creates unsafe values accessible by safe code? No it only returns a Boolean.
- unsafe aliasing accessible by safe code? No aliasing whatsoever.

Reply via email to