[Issue 4406] Typo (bug) in std.concurrency

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 29 07:53:43 PDT 2010


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



--- Comment #2 from Simen Kjaeraas <simen.kjaras at gmail.com> 2010-06-29 07:53:41 PDT ---
(In reply to comment #1)
> Ops is a type, I don't think that will compile.
> 
> I'd say a more complex solution is needed:
> 
>         final void get(T...)( T _ops )
>         {
>             static assert( T.length );
> 
>             static if( isImplicitlyConvertible!(T[0], long) )
>             {
>                 alias TypeTuple!(T[1 .. $]) Ops;
>                 enum timedWait = true;
>                 assert( _ops[0] >= 0 );
>                 long period = _ops[0];
>                 Ops ops = _ops[1 .. $];  // Line 609
>             }
>             else
>             {
>                  alias TypeTuple!(T) Ops;
>                  enum timedWait = false;
>                  alias _ops ops; // not sure if this works
>             }
> 
> If the alias doesn't work, you may have to do something with the function
> signature.  I'm not sure how assigning _ops to ops will work, it may invoke
> some unnecessary ctors/dtors.

I don't think it's necessary to to assign anything the way you do. All that's
needed is renaming the ops argument to _ops, and adding an alias in both
clauses of the static if:

        final void get(T...)( T _ops )
        {
            static assert( T.length );

            static if( isImplicitlyConvertible!(T[0], long) )
            {
                alias TypeTuple!(T[1 .. $]) Ops;
                enum timedWait = true;
                assert( ops[0] >= 0 );
                long period = ops[0];
                alias _ops[1 .. $] ops; // Here
            }
            else
            {
                alias TypeTuple!(T) Ops;
                enum timedWait = false;
                alias _ops ops; // And here
            }

-- 
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