Thread overview
[Issue 11706] std.traits.OriginalType should support std.typecons.Typedef
[Issue 11706] Alias to the original type inside std.typecons.Typedef
Apr 24, 2014
Andrej Mitrovic
Apr 24, 2014
Andrej Mitrovic
Apr 24, 2014
Andrej Mitrovic
[Issue 11706] Add a TypedefType trait to extract the underlying type of a std.typecons.Typedef
Apr 24, 2014
Andrej Mitrovic
April 22, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #1 from bearophile_hugs@eml.cc ---
An alternative solution is to use something in std.traits to get the underlying type of a Typedef.

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com

--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
(In reply to bearophile_hugs from comment #1)
> An alternative solution is to use something in std.traits to get the underlying type of a Typedef.

That's a fantastic idea, and we can implement this thanks to recent compiler improvements. A pull is coming.

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Assignee|nobody@puremagic.com        |andrej.mitrovich@gmail.com
            Summary|Alias to the original type  |std.traits.OriginalType
                   |inside std.typecons.Typedef |should support
                   |                            |std.typecons.Typedef

--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
https://github.com/D-Programming-Language/phobos/pull/2116

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #4 from bearophile_hugs@eml.cc ---
(In reply to Andrej Mitrovic from comment #3)
> https://github.com/D-Programming-Language/phobos/pull/2116

Thank you. But:

> // safely cast to get the value that's being wrapped
> int x = cast(OriginalType!MyInt)myInt;

casts are not safe. That example is not good.

Safer and shorter:

int x = myInt.get;

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
(In reply to bearophile_hugs from comment #4)
> (In reply to Andrej Mitrovic from comment #3)
> > https://github.com/D-Programming-Language/phobos/pull/2116
> 
> Thank you. But:
> 
> > // safely cast to get the value that's being wrapped
> > int x = cast(OriginalType!MyInt)myInt;
> 
> casts are not safe. That example is not good.
> 
> Safer and shorter:
> 
> int x = myInt.get;

That's not safer if 'myInt' is a UDT that happens to define get(). You may end up calling a function that returns something else entirely.

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #6 from bearophile_hugs@eml.cc ---
(In reply to Andrej Mitrovic from comment #5)

> That's not safer if 'myInt' is a UDT that happens to define get(). You may end up calling a function that returns something else entirely.

Right, sorry, see my comments in Issue 12597

--
April 24, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.traits.OriginalType     |Add a TypedefType trait to
                   |should support              |extract the underlying type
                   |std.typecons.Typedef        |of a std.typecons.Typedef

--
September 08, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--
September 08, 2014
https://issues.dlang.org/show_bug.cgi?id=11706

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/f9048c94ef834b683b1ce30f5722c9e0969cdf74
Fix Issue 11706 - Add a TypedefType trait to extract the underlying type
of a std.typecons.Typedef.

https://github.com/D-Programming-Language/phobos/commit/bf8d579d590bc89d9a7462cbc366fc97665e4a73 Merge pull request #2116 from AndrejMitrovic/Fix11706

Issue 11706 - Add a TypedefType trait to extract the underlying type of a std.typecons.Typedef

--