Fix typeof(null) being a pointer for isPointer

This commit is contained in:
Eugen Wissner 2018-03-25 09:19:35 +02:00
parent 162db622ea
commit 9fb043ba65
3 changed files with 16 additions and 3 deletions

View File

@ -9,7 +9,7 @@
* to transform from one type to another. It has also different algorithms for
* iterating, searching and modifying template arguments.
*
* Copyright: Eugene Wissner 2017.
* Copyright: Eugene Wissner 2017-2018.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)

View File

@ -735,7 +735,7 @@ template isPointer(T)
{
static if (is(T U : U*))
{
enum bool isPointer = true;
enum bool isPointer = !is(Unqual!(OriginalType!T) == typeof(null));
}
else
{
@ -752,6 +752,19 @@ template isPointer(T)
static assert(!isPointer!bool);
}
// typeof(null) is not a pointer.
@nogc nothrow pure @safe unittest
{
static assert(!isPointer!(typeof(null)));
static assert(!isPointer!(const shared typeof(null)));
enum typeOfNull : typeof(null)
{
null_ = null,
}
static assert(!isPointer!typeOfNull);
}
/**
* Determines whether $(D_PARAM T) is an array type (dynamic or static, but
* not an associative one).

View File

@ -9,7 +9,7 @@
* types. They take some type as argument and return a different type after
* perfoming the specified transformation.
*
* Copyright: Eugene Wissner 2017.
* Copyright: Eugene Wissner 2017-2018.
* License: $(LINK2 https://www.mozilla.org/en-US/MPL/2.0/,
* Mozilla Public License, v. 2.0).
* Authors: $(LINK2 mailto:info@caraus.de, Eugene Wissner)