Can it not be possible to use alias this on a private field?

struct Q
   private:
      int _x;
   public:
      alias _x this;

?

Seems to me that one does not always want the user to access the internal value that is aliased ;/


Q q;

q._x // error yet q, for all practical purposes is _x, we just stop the user from being able to directly access it.

For example, maybe I want to override opAssign on an int. The user can get around it by doing q._x. Seems like a bad idea.


Reply via email to