[Issue 7989] isInputRange and isForwardRange declare unused variables

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 26 07:16:45 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7989


Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com


--- Comment #1 from Steven Schveighoffer <schveiguy at yahoo.com> 2012-04-26 07:17:50 PDT ---
(In reply to comment #0)

> -        auto h = r.front; // can get the front of the range
> +        cast(void) r.front; // can get the front of the range

front should return a value, returning void is not acceptable, but this would
pass your code.

I think this might work better:

static assert(is(typeof(r.front) != void));

It may also be required that front can be used to initialize a variable (I
think there may be some cases where a non-void value cannot be used this way,
but I'm not sure).  How do you test for this, and then 'use' the variable later
when you have no idea how it can be used?  I suppose you could pass it to a
function template?

This kind of requirement is going to be problematic, possibly in a lot of
places.  It might make sense to define some more helper enums for this, like
isNonVoidInitializer or something like that.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list