Bug? Const Class Makes Constructor Const

Vijay Nayar madric at gmail.com
Thu Oct 25 19:23:35 UTC 2018


void main()
{
   const class Bob {
     this() {
       bob = null;
     }
     Bob bob;
   }

   Bob b = new Bob();
}

Compiling this program gives the following error:

onlineapp.d(10): Error: constructor `onlineapp.main.Bob.this() 
const` is not callable using argument types `()`

I know that declaring a 'const class' adds 'const' to every 
member of the class, but does that even include constructors?  
I'm not sure how one could use a class with a const constructor.  
Is this a bug?


More information about the Digitalmars-d mailing list