[Issue 9112] Uniform construction for built-in types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 6 22:30:33 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9112


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #9 from monarchdodra at gmail.com 2012-12-06 22:30:28 PST ---
(In reply to comment #1)
> This is useful in generic code:
> int n = int(10);

EXTREMELY useful. Just the other day, I was writing a unittest to cover
appender with as many types as possible, and wanted to write something along
the lines of:

//----
foreach (SS; TypeTuple!(int, S0, S1, S2, S3, S4, S5, S6, S7))
{
    foreach (S; TypeTuple!(SS, const(SS), immutable(SS)))
    {
        auto app1 = appender!(S[])();
        foreach(i; 0 .. 0x20000)
            app1.put(S(i)); // HERE
//----
Long story short: "int" didn't make it into the final test...

(In reply to comment #2)
> What I really want to be able to do is stuff like
> 
> auto i = new int(5);
> auto j = new immutable(int)(7);
> 
> Right now, you have to do nonsense like
> 
> auto i = new int;
> *i = 5;

You always have the 
auto j = [cast(immutable int)5].ptr;
"Trick". But that's still ugly as sin, and I'm not sure what you are actually
paying for when doing this.

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


More information about the Digitalmars-d-bugs mailing list