On Friday, 24 June 2016 at 03:04:25 UTC, Mike Parker wrote:
On Friday, 24 June 2016 at 02:57:28 UTC, "Smoke" Adams wrote:
Is there a type of __THIS__ construct similar to __FILE__ and __LINE__?

Something that returns the current this ptr if it exists, null otherwise.

Log(string filename = __FILE__, Object obj = __THIS__)()
{
   // inspect obj and do stuff
}

There is no 'this' pointer unless you are calling a member function on an aggregate, so you can never have one that is null.

Oh, perhaps I misunderstood your question. Do you meant this:

class Foo() {
   void bar() { Log(); }  // Pass reference to Foo instance
}

void doSomething() { Log(); } // Null reference

If so, the answer is no. And I don't see how that could work as a compile time parameter, given that the reference itself is a runtime value.

Reply via email to