<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
12.08.2010 17:13, simendsjo wrote:
<blockquote cite="mid:i40s2i$271n$1@digitalmars.com" type="cite">The
spec doesn't mention anything about block statements in typeof
declarations.
<br>
<br>
//typeof({1}) a; // found } expecting ;
<br>
//typeof({1}()) b; // same as a
<br>
typeof(1) c; // int
<br>
<br>
I'm asking because isInputRange from std.range the idom from the b
test:
<br>
<br>
template isInputRange(R)
<br>
{
<br>
enum bool isInputRange = is(typeof(
<br>
{
<br>
R r; // can define a range object
<br>
if (r.empty) {} // can test for empty
<br>
r.popFront; // can invoke next
<br>
auto h = r.front; // can get the front of the range
<br>
}()));
<br>
}
<br>
<br>
</blockquote>
This looks like a parameterless delegate to me :) Seems something
akin to __traits(compiles).<br>
<blockquote cite="mid:i40s2i$271n$1@digitalmars.com" type="cite">
<br>
Also... The unittest contains
<br>
static assert(isInputRange!(int[]));
<br>
static assert(isInputRange!(char[]));
<br>
<br>
But arrays doesn't include these methods.. I don't understand a
thing :(
<br>
</blockquote>
They don't, but std.array imported in std.range defines the methods
for them.<br>
<br>
<div class="moz-signature">-- <br>
<table style="border: 0px none; font-family: Segoe UI; font-size:
8pt;" width="100%">
<tbody>
<tr>
<td width="50%">
<b><br>
</b>
</td>
<td><br>
<b></b>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>