From f20c5bfd7804660ecfe890f3d420dadda599e3b2 Mon Sep 17 00:00:00 2001 From: Daniel Zullo Date: Tue, 29 Oct 2019 23:53:53 +0100 Subject: [PATCH] Fix function to check for UTF-8 string type The function `ocean.meta.traits.Arrays.isUTF8StringType()` is suggested to replace the deprecated `ocean.core.Traits.isStringType()` but it failed to check for static arrays and now it is fixed to support both basic kind of arrays. Fixes #778 --- relnotes/fix-is-string-type.bug.md | 10 ++++++++++ src/ocean/meta/traits/Arrays.d | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 relnotes/fix-is-string-type.bug.md diff --git a/relnotes/fix-is-string-type.bug.md b/relnotes/fix-is-string-type.bug.md new file mode 100644 index 000000000..e0fb800ca --- /dev/null +++ b/relnotes/fix-is-string-type.bug.md @@ -0,0 +1,10 @@ +### Fix function to check for UTF-8 string type + +`ocean.meta.traits.Arrays` + +The function `ocean.meta.traits.Arrays.isUTF8StringType()` is suggested to +replace the deprecated `ocean.core.Traits.isStringType()` but it failed to +check for static arrays and now it is fixed to support both basic kind of +arrays. + +Fixes #778 diff --git a/src/ocean/meta/traits/Arrays.d b/src/ocean/meta/traits/Arrays.d index 940823b17..0c7a0328e 100644 --- a/src/ocean/meta/traits/Arrays.d +++ b/src/ocean/meta/traits/Arrays.d @@ -35,13 +35,13 @@ import ocean.meta.types.Qualifiers; template isUTF8StringType ( T ) { static immutable isUTF8StringType = - isArrayType!(T) == ArrayKind.Dynamic - && is(Unqual!(ElementTypeOf!(T)) == char); + isBasicArrayType!(T) && is(Unqual!(ElementTypeOf!(T)) == char); } /// unittest { + static assert (isUTF8StringType!(char[1])); static assert (isUTF8StringType!(char[])); static assert (isUTF8StringType!(Immut!(char)[])); static assert (!isUTF8StringType!(wchar[]));