Type Qualifiers and Wild Cards

Martin Nowak dawg at dawgfoto.de
Tue Nov 8 15:57:19 PST 2011


On Wed, 09 Nov 2011 00:01:09 +0100, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 11/8/2011 11:10 AM, Martin Nowak wrote:
>> I personally find it much more astonishing that inout methods finally  
>> work.
I literally meant methods as in member functions.
Being able to use inout as method qualifier is way more
important than achieving the same for free functions as it
makes transitive qualifiers almost hassle free in simple cases.

>
> In retrospect, it seems like a fairly straightforward solution, but it  
> took us many, many hours and gallons of coffee. And, as far as I know,  
> this solution has not been seen before in any other language, though  
> there is a crying need for it in C++.

Yeah, the two common C++ solutions are either overload macros or  
non-transitive const.
Remarkably enough it's hardly understood in a C++ context that transitive
qualifiers offer much stronger guarantees.
Take shared_ptr as a prominent example for the disaster.

       _Tp*
       get() const // never throws
       { return _M_ptr; }

With the even worse C++ solution to this being const_iterator.


More information about the Digitalmars-d mailing list