const and non-const member function

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Jul 26 00:33:02 PDT 2007


Christian Kamm wrote:
>> (I'm also not 100% pleased with the 'const R M(){}' syntax for declaring
>> const methods...  
> 
> Yes, it's quite bad:
> 
> const Foo func(const Foo)
> {
>   const Foo = ...;
> }
> 
> All consts look the same, but the first means the method, the second is an
> alternative for const(Foo) and the third is the compile-time const storage
> class. 
> I'd probably disallow const Foo in parameter declarations, yet don't know
> how to do make the method-const look different.

How about this for method-const:
---
Foo const(func)(const Foo) {
     // ...
}
---
Though I guess that may look too much like the const(Type) notation...


More information about the Digitalmars-d-learn mailing list