www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14830] New: RefCounted does not forward all fields of

https://issues.dlang.org/show_bug.cgi?id=14830

          Issue ID: 14830
           Summary: RefCounted does not forward all fields of underlying
                    data structure
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: joseph.wakeling webdrake.net

Observed when trying to create a ref-counted random number generator:

    import std.random, std.typecons;
    static assert(isUniformRNG!Random);
    static assert(isUniformRNG!(RefCounted!Random)); // FAILS

So far as I can tell, the problem is the check for the existence of the
isUniformRandom boolean enum in the isUniformRNG template check:
https://github.com/D-Programming-Language/phobos/blob/master/std/random.d#L137-L140

i.e. while this check passes:

    static assert(is(typeof(Random.isUniformRandom)));

this corresponding one fails:

    static assert(is(typeof((RefCounted!Random).isUniformRandom)));

Clearly one could put the blame on the isUniformRNG template check here, but my
feeling is that RefCounted should be able to forward _all_ properties and
fields of the underlying type, including compile-time enum flags like
isUniformRandom.

--
Jul 26 2015