On Saturday, 24 July 2021 at 18:10:07 UTC, Alexey wrote:
The goal I with to achieve by this check - is to use template
and to assign value to variable basing on it's ability to
accept null as a value.
The most direct representation of that is __traits(compiles, (T
t) { t = null; });
On Saturday, 24 July 2021 at 20:10:37 UTC, JG wrote:
On Saturday, 24 July 2021 at 19:39:02 UTC, Alexey wrote:
[...]
There are probably better ways. However, this seems to work:
```d
import std;
enum canBeSetToNull(T) = __traits(compiles,(T.init is null));
interface I1
{
}
class C1 : I1
{
}
On Saturday, 24 July 2021 at 19:39:02 UTC, Alexey wrote:
On Saturday, 24 July 2021 at 18:10:07 UTC, Alexey wrote:
I've tried to use ```typeof(t) is cast(t)null```, but compiler
exits with error and so this can't be used for checking this
issue.
The goal I with to achieve by this check - is
On Saturday, 24 July 2021 at 18:10:07 UTC, Alexey wrote:
I've tried to use ```typeof(t) is cast(t)null```, but compiler
exits with error and so this can't be used for checking this
issue.
The goal I with to achieve by this check - is to use template
and to assign value to variable basing on
I've tried to use ```typeof(t) is cast(t)null```, but compiler
exits with error and so this can't be used for checking this
issue.
The goal I with to achieve by this check - is to use template and
to assign value to variable basing on it's ability to accept null
as a value.
some testing