Skip to content

Commit

Permalink
Fix function to check for UTF-8 string type
Browse files Browse the repository at this point in the history
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 sociomantic-tsunami#778
  • Loading branch information
Daniel Zullo committed Oct 29, 2019
1 parent 19bd05b commit 4d7e224
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions relnotes/fix-is-string-type.bug.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions src/ocean/meta/traits/Arrays.d
Original file line number Diff line number Diff line change
Expand Up @@ -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[]));
Expand Down

0 comments on commit 4d7e224

Please sign in to comment.