Const vs Non const method
Namespace via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 7 10:44:01 PST 2016
On Monday, 7 March 2016 at 18:17:18 UTC, Ola Fosheim Grøstad
wrote:
> On Monday, 7 March 2016 at 16:30:48 UTC, Namespace wrote:
>> Thanks to the wildcard modifier inout. Is there any possible
>> way to do the same in C++?
>
> In this specific case you could do it with a macro if you don't
> mind dirty macros, but you really should implement the const
> version explicitly or use a free function that cover both cases
> using templating.
>
> If you are looking for information on C++ you probably should
> use stack overflow:
>
> http://stackoverflow.com/questions/7792052/c-template-to-cover-const-and-non-const-method
Honestly speaking, I think this case is impossible to solve in
C++. I'll show my fellow students the advantages of D over C++ in
next couple of weeks, and this example is pretty good. :)
More information about the Digitalmars-d-learn
mailing list