Hi there,
I recently read the 'More Templates' chapter of Ali's book (<-- thanks
for that ;) ).
At the section 'Named constraints', there were a definition like this:
template isUsable(T)
{
enum isUsable = is ( typeof(
{
T obj;
obj.call();
obj.otherCall(1);
obj.ye tAnotherCall();
}() ) );
}
But at Phobos I always see definitions like this (std.range : isInputRange):
template isInputRange(R)
{
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {} // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}));
} What does (inout int = 0) mean/affect here? I created the same
template for myself just without the (inout int = 0) and it worked (at
least with a dummy struct).. - Tim