[Issue 5747] cannot cast away shared if opCast defined

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 11 12:38:26 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=5747



--- Comment #7 from monarchdodra at gmail.com 2013-12-11 12:38:23 PST ---
(In reply to comment #6)
> (In reply to comment #4)
> 
> >     {
> >         return this; //This fails
> >         return cast(T) this; //This overflows
> >     }
> 
> That's expected. It is easy to break the recursion:

Your example snippet still overflows for me for the initial use case:

void main()
{
    immutable(S) s;
    auto b = cast(S)(s); //How to do this?
}

> I think the fix to issue 11722 has introduced an unnecessary limitation
> (provided other annoyances are removed, such as opCast not being called if
> types match exactly).

*What* limitations?

If we *really* wanted to overload a "qualifier cast", then arguably, we could
add an enhancement request for something like:

auto opCast(); //Removes qualifier cast
auto opCast(const); //Adds const
auto opCast(shared); //Adds shared

But I really don't see how a *type* cast should interfere a *qualifier* cast.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list