On Wednesday, 20 November 2013 at 22:49:42 UTC, Spott wrote:
I've been screwing around with templates lately, and I'm
attempting to figure out why the following won't compile:

struct value
{
     int a;

     const auto
         opBinary(string op, T)(in T rhs) const pure {
             static if (op == "+")
return intermediateValue!(value.plus,this,rhs)();
         }

const here is redundant, probably wanted const(auto) which isn't valid syntax. The function being const may already be returning a const type.

What is going on?  Why is 'a' not allowed to "access" mutable
data (even though it isn't modifying it)? How do I tell the
compiler to pass "this" in a const fashion?

I'm not seeing an issue with the declarations. The function being declared as const is what make 'this' const. Probably should file as a bug if you don't get any confirmation soon. And reply with the bug entry.

Reply via email to