Skip to content

Commit 64c2c92

Browse files
nordlowthewilsonator
authored andcommitted
Replace templates with templated enums in std/random.d
1 parent db880b4 commit 64c2c92

File tree

1 file changed

+22
-34
lines changed

1 file changed

+22
-34
lines changed

std/random.d

Lines changed: 22 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,17 @@ version (StdUnittest)
247247
* $(LI it has a 'bool isUniformRandom' field readable in CTFE)
248248
* )
249249
*/
250-
template isUniformRNG(Rng, ElementType)
251-
{
252-
enum bool isUniformRNG = .isUniformRNG!Rng &&
253-
is(std.range.primitives.ElementType!Rng == ElementType);
254-
}
250+
enum isUniformRNG(Rng, ElementType) = .isUniformRNG!Rng &&
251+
is(std.range.primitives.ElementType!Rng == ElementType);
255252

256253
/**
257254
* ditto
258255
*/
259-
template isUniformRNG(Rng)
260-
{
261-
enum bool isUniformRNG = isInputRange!Rng &&
262-
is(typeof(
263-
{
264-
static assert(Rng.isUniformRandom); //tag
265-
}));
266-
}
256+
enum isUniformRNG(Rng) = isInputRange!Rng &&
257+
is(typeof(
258+
{
259+
static assert(Rng.isUniformRandom); //tag
260+
}));
267261

268262
///
269263
@safe unittest
@@ -311,29 +305,23 @@ template isUniformRNG(Rng)
311305
* $(LI it has a 'seed(ElementType)' function)
312306
* )
313307
*/
314-
template isSeedable(Rng, SeedType)
315-
{
316-
enum bool isSeedable = isUniformRNG!(Rng) &&
317-
is(typeof(
318-
{
319-
Rng r = void; // can define a Rng object
320-
SeedType s = void;
321-
r.seed(s); // can seed a Rng
322-
}));
323-
}
308+
enum isSeedable(Rng, SeedType) = isUniformRNG!(Rng) &&
309+
is(typeof(
310+
{
311+
Rng r = void; ///< can define a Rng object
312+
SeedType s = void; ///< Dummy doc to silence D-scanner.
313+
r.seed(s); // can seed a Rng
314+
}));
324315

325316
///ditto
326-
template isSeedable(Rng)
327-
{
328-
enum bool isSeedable = isUniformRNG!Rng &&
329-
is(typeof(
330-
{
331-
Rng r = void; // can define a Rng object
332-
alias SeedType = typeof(r.front);
333-
SeedType s = void;
334-
r.seed(s); // can seed a Rng
335-
}));
336-
}
317+
enum isSeedable(Rng) = isUniformRNG!Rng &&
318+
is(typeof(
319+
{
320+
Rng r = void; ///< can define a Rng object
321+
alias SeedType = typeof(r.front);
322+
SeedType s = void; ///< Dummy doc to silence D-scanner.
323+
r.seed(s); // can seed a Rng
324+
}));
337325

338326
///
339327
@safe unittest

0 commit comments

Comments
 (0)