Skip to content

Commit 6e6fde7

Browse files
authored
clarify what isIntegral, isScalar, etc. __traits mean (#3588)
1 parent a852806 commit 6e6fde7

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

spec/traits.dd

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ $(H3 $(GNAME isArithmetic))
103103
Otherwise, $(D false) is returned.
104104
If there are no arguments, $(D false) is returned.)
105105

106+
$(P Arithmetic types are integral types and floating point types.)
107+
106108
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
107109
---
108110
import std.stdio;
@@ -129,8 +131,17 @@ false
129131

130132
$(H3 $(GNAME isFloating))
131133

132-
$(P Works like $(D isArithmetic), except it's for floating
133-
point types (including imaginary and complex types).)
134+
$(P If the arguments are all either types that are floating point types,
135+
or expressions that are typed as floating point types, then $(D true)
136+
is returned.
137+
Otherwise, $(D false) is returned.
138+
If there are no arguments, $(D false) is returned.)
139+
140+
$(P The floating point types are:
141+
`float`, `double`, `real`,
142+
`ifloat`, `idouble`, `ireal`,
143+
`cfloat`, `cdouble`, `creal`,
144+
vectors of floating point types, and enums with a floating point base type.)
134145

135146
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
136147
---
@@ -148,8 +159,16 @@ static assert(!__traits(isFloating, float[4]));
148159

149160
$(H3 $(GNAME isIntegral))
150161

151-
$(P Works like $(D isArithmetic), except it's for integral
152-
types (including character types).)
162+
$(P If the arguments are all either types that are integral types,
163+
or expressions that are typed as integral types, then $(D true)
164+
is returned.
165+
Otherwise, $(D false) is returned.
166+
If there are no arguments, $(D false) is returned.)
167+
168+
$(P The integral types are:
169+
`byte`, `ubyte`, `short`, `ushort`, `int`, `uint`, `long`, `ulong`, `cent`, `ucent`,
170+
`bool`, `char`, `wchar`, `dchar`,
171+
vectors of integral types, and enums with an integral base type.)
153172

154173
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
155174
---
@@ -171,8 +190,17 @@ static assert(!__traits(isIntegral, void*));
171190

172191
$(H3 $(GNAME isScalar))
173192

174-
$(P Works like $(D isArithmetic), except it's for scalar
175-
types.)
193+
$(P If the arguments are all either types that are scalar types,
194+
or expressions that are typed as scalar types, then $(D true)
195+
is returned.
196+
Otherwise, $(D false) is returned.
197+
If there are no arguments, $(D false) is returned.)
198+
199+
$(P Scalar types are integral types,
200+
floating point types,
201+
pointer types,
202+
vectors of scalar types,
203+
and enums with a scalar base type.)
176204

177205
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
178206
---
@@ -198,8 +226,16 @@ static assert(!__traits(isScalar, Object));
198226

199227
$(H3 $(GNAME isUnsigned))
200228

201-
$(P Works like $(D isArithmetic), except it's for unsigned
202-
types.)
229+
$(P If the arguments are all either types that are unsigned types,
230+
or expressions that are typed as unsigned types, then $(D true)
231+
is returned.
232+
Otherwise, $(D false) is returned.
233+
If there are no arguments, $(D false) is returned.)
234+
235+
$(P The unsigned types are:
236+
`ubyte`, `ushort`, `uint`, `ulong`, `ucent`,
237+
`bool`, `char`, `wchar`, `dchar`,
238+
vectors of unsigned types, and enums with an unsigned base type.)
203239

204240
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
205241
---

0 commit comments

Comments
 (0)