Yes you can use __LINE__. In addition, __FILE__.
See Keywords section.
As noted by BCS and Jonathan M Davis in the comments, __LINE__there is a special case for friends: when using the function as the default value for the template or argument, they allow the location of the caller, not the signature of the template or function. This is great for preventing users from providing this information.
void myAssert(T)(lazy T expression, string file = __FILE__, int line = __LINE__)
{
if (!expression)
{
writefln("Assert failure at %s:%s", file, line);
}
}
source
share