Say I have the following struct and object definitions:
struct Test1(T)
{
static if (???)
{
void doSomething()
{
writeln(typeof(this).stringof);
}
}
T t;
}
class Test2(T)
{
static if (???)
{
void doSomething()
{
On Thursday, 6 November 2014 at 23:43:19 UTC, Meta wrote:
How can I tell at the points marked in the above code if the
class or struct instance was declared as const, shared, etc.?
Is this possible?
You can't do that, but you can overload on const
void doSomething() const { called on const
One other thing. I know about `template this`, but I'm not sure
if that's a tenable solution or not in my case. In addition to
templating the struct or class, would I not also have to template
the constructor so it could pick up the type of `this` at the
declaration site?