Detecting value parameter of template instance in "is" expression
Uranuz
neuranuz at gmail.com
Thu Dec 5 12:07:50 PST 2013
I'm trying to detect values that were instantiated from
std.typecons.Nullable (and NullableRef). And I will net to get
base types of these Nullable values. For simplicity I write the
following code to test for Nullable.
//-------------------
import std.stdio, std.typecons;
template isStdNullable(N)
{
static if(
is( N == Nullable!(T), T )
|| is( N == NullableRef!(T), T )
|| is( N == Nullable!(T, nV), T, T nV ) //There is an error
)
enum bool isNullable = true;
else
enum bool isNullable = false;
}
void main()
{
writeln(isStdNullable!(Nullable!(int, 10)));
}
//-----------------
Compilation output:
/d966/f969.d(8): Error: undefined identifier T, did you mean
alias N?
/d966/f969.d(19): Error: template instance
f969.isStdNullable!(Nullable!(int, 10)) error instantiating
How should I define value parameters inside "is" expression to
make code like this working?
More information about the Digitalmars-d-learn
mailing list