www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - const class

reply "Oleg" <code.viator gmail.com> writes:
Hello. I can't find siple way to realization this behavior:

[code]
class A
{
   A parent;

   void someFunc() const { }

   void parentCall() const
   {
      const(A) cur = this;
      while( cur )
      {
        cur.someFunc();
        cur = cur.parent;
      }
   }
}
[/code]

error: cannot modify const expression cur

how create variable that store const object and can be changed to 
other const object?
Nov 26 2014
parent "bearophile" <bearophileHUGS lycos.com> writes:
Oleg:

 how create variable that store const object and can be changed 
 to other const object?
Take a look at std.typecons.Rebindable/std.typecons.rebindable. Read all Phobos documentation, it helps. Bye, bearophile
Nov 26 2014